Hello...
I am executing the following JavaScript code on the WorkItemComplete Handler event. It is working perfectly well using Internet Explorer. But it is not working in Firefox or Chrome. It throwss an error: Application(s) is/are icomplete. Are you sure you want to complete the Work Item?
Any suggestions?
Thanks.
var sub_deadline = document.getElementById("SUBMISSION_DEADLINE").value;
var currentdate = new Date();
var dt1 = parseInt(sub_deadline.substring(3,5),10);
var mon1 = parseInt(sub_deadline.substring(0,2),10) - 1;
var yr1 = parseInt(sub_deadline.substring(6,10),10);
var subdate = new Date(yr1, mon1, dt1);
var todaysDate = new Date(currentdate.getFullYear(), currentdate.getMonth(),currentdate.getDate());
var timeDiff = subdate - todaysDate;
var yearnbr = document.getElementById("YEAR_NUMBER").value;
var totalyrs = document.getElementById("TOTAL_YEARS").value;
var totalcost = document.getElementById("CURRENT_REQ_TOTAL_COST").value;
var validate;
validate = 0;
if (totalcost == 0)
{
validate = 1;
document.getElementById("alertmessage").innerHTML = "Total current cost must be greater than 0";
}
if (totalyrs < 1)
{
validate = 1;
document.getElementById("alertMessage").innerHTML = "Total Years entered must be be greater than/equal to 1";
}
if (yearnbr < 1)
{
validate = 1;
document.getElementById("alertMessage").innerHTML = "Year Number entered must be be greater than/equal to 1";
}
if (subdate.getTime() <= todaysDate.getTime())
{
document.getElementById("alertMessage").innerHTML = "Submission Deadline must be a date in the future";
validate = 1;
}
if (validate == 0)
{
objAction = {name: 'Action', option: 'Action', value: 'saveNewForm'};
var objValidate = {name: 'Validate', option: 'Static', value: 'true'};
var success = hyf.FMAction.handleFormSubmission(objAction, objValidate, objEventSource);
if (success) BasicWIHAction.setWait();
else BasicWIHAction.setStop();
}
else if(validate != 0)
{
dijit.byId("alertMessageBox").show();
BasicWIHAction.setStop();
}
I am executing the following JavaScript code on the WorkItemComplete Handler event. It is working perfectly well using Internet Explorer. But it is not working in Firefox or Chrome. It throwss an error: Application(s) is/are icomplete. Are you sure you want to complete the Work Item?
Any suggestions?
Thanks.
var sub_deadline = document.getElementById("SUBMISSION_DEADLINE").value;
var currentdate = new Date();
var dt1 = parseInt(sub_deadline.substring(3,5),10);
var mon1 = parseInt(sub_deadline.substring(0,2),10) - 1;
var yr1 = parseInt(sub_deadline.substring(6,10),10);
var subdate = new Date(yr1, mon1, dt1);
var todaysDate = new Date(currentdate.getFullYear(), currentdate.getMonth(),currentdate.getDate());
var timeDiff = subdate - todaysDate;
var yearnbr = document.getElementById("YEAR_NUMBER").value;
var totalyrs = document.getElementById("TOTAL_YEARS").value;
var totalcost = document.getElementById("CURRENT_REQ_TOTAL_COST").value;
var validate;
validate = 0;
if (totalcost == 0)
{
validate = 1;
document.getElementById("alertmessage").innerHTML = "Total current cost must be greater than 0";
}
if (totalyrs < 1)
{
validate = 1;
document.getElementById("alertMessage").innerHTML = "Total Years entered must be be greater than/equal to 1";
}
if (yearnbr < 1)
{
validate = 1;
document.getElementById("alertMessage").innerHTML = "Year Number entered must be be greater than/equal to 1";
}
if (subdate.getTime() <= todaysDate.getTime())
{
document.getElementById("alertMessage").innerHTML = "Submission Deadline must be a date in the future";
validate = 1;
}
if (validate == 0)
{
objAction = {name: 'Action', option: 'Action', value: 'saveNewForm'};
var objValidate = {name: 'Validate', option: 'Static', value: 'true'};
var success = hyf.FMAction.handleFormSubmission(objAction, objValidate, objEventSource);
if (success) BasicWIHAction.setWait();
else BasicWIHAction.setStop();
}
else if(validate != 0)
{
dijit.byId("alertMessageBox").show();
BasicWIHAction.setStop();
}
RE: Data Validation on WorkItem Handler-Browser Issue
Without being able to actually run the code it is hard to say exactly what the issue is.
I think that you might get the alert message you mention if an error has occurred in the script, so the first thing I would try is wrapping your code in a try/catch block to see if that catches anything, eg:
try { //your code here } catch (e) { alert(e.message); }
Regards,
Gerard
RE: Data Validation on WorkItem Handler-Browser Issue
This issue has been resolved. The problem was a caps mismatch on the field name ("alertMessage"). It should be lower case m ("alertmessage"). It looks like IE does not care about the mismatch, but Firefox and Chrome does.
Thank you for your help.
John H.