onChange script error: ReferenceError: 'validateStartDateBeforeEndDate' er ikke defineret function

Kenneth19
Tera Contributor

When using ui policies to set start date and end date automatically i get this error when create new change. The error appears in New York but worked fine in London release

Listed below is error in screendump, the policy and further down the error in text

find_real_file.png

 

*******  UI Policy ******

function onCondition() {

function AddZero(num) {
return (num >= 0 && num < 10) ? "0" + num : num + "";
}
var n = new Date();
g_form.setValue('end_date',AddZero(n.getDate()) + "-" + AddZero(n.getMonth() + 1) + "-" + AddZero(n.getFullYear()) + " " + AddZero(n.getHours()+12) + ":" + AddZero(n.getMinutes()+5) + ":" + AddZero(n.getSeconds()));
g_form.setValue('start_date',AddZero(n.getDate()) + "-" + AddZero(n.getMonth() + 1) + "-" + AddZero(n.getFullYear()) + " " + AddZero(n.getHours()+6) + ":" + AddZero(n.getMinutes()+5) + ":" + AddZero(n.getSeconds()) );

}

 

*** ERROR ****

onChange script error: ReferenceError: 'validateStartDateBeforeEndDate' er ikke defineret function onChange_change_request_start_date_0(control, oldValue, newValue, isLoading, isTemplate) { if (isLoading || newValue === '') return; var showErrorMsg = function(errorMsg){ g_form.showErrorBox("end_date", errorMsg); }; g_form.hideFieldMsg("end_date", true); if (validateStartDateBeforeEndDate("start_date", "end_date", showErrorMsg) && (typeof validateMaxDateDuration !== "undefined")) validateMaxDateDuration("start_date", "end_date", showErrorMsg); }

 

 

6 REPLIES 6

VigneshMC
Mega Sage

Error seems to be from a different script, it should be a onchange client script which is throwing this.

Thanks

Pnik
Tera Contributor

Hi Vignesh,

we are also facing this error in madrid version & yes, as you said its referring to a below Client script. it seems OOBT script, could you suggest on this .

Hi Kenneth - did you able to resolve it..?find_real_file.png

 

AndyLock
Mega Guru

 

it looks like the client script now checks that the ui script exists. here's a snippet:

if (typeof validateMaxDateDuration !== "undefined") { // Need to check if the method exist in case StartEndDateValidation UI Script has been skipped during upgrade

 

Have you got the latest patch?

 

Sandeep Rajput
Tera Patron
Tera Patron

Though this is a six months old post, I am posting an answer here as many others can get benefitted from it.

According to the error, Javascript compiler has not been able to find method validateStartDateBeforeEndDate function within the UIScript, this OOTB function is part of UI Script with the name "StartEndDateValidation". Check if this UI Script exists in your instance. Since this UI Script is not a global script, one has to load this script with an onLoad client script, OOTB does it using OOTB client script "Date Validation Load" which is defined for both change_request and change_task. Once both these scripts are there on the instance, the compilation error would go away on its own.