GlideDateTime is not defined function error on client script populated field

Ondrej Kieler
Kilo Contributor

Hello,

I have created custom field u_on_hold_reminder. This field should be populated by current time + 14 days when On hold reason is Awaiting caller. I created client script which is calling script include to fulfill this.

Script include:

var ClientDateTimeUtils = Class.create();
ClientDateTimeUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
//Returns the Date/Time of right now + 14 days.
getNowDateTimePlus14: function(){
var date = this.getParameter('sysparm_addDays');
var second = this.getParameter('sysparm_addSeconds');
var now = new GlideDateTime(); // Sets current time to now variable

now.addDays(date); // Adds some days into now variable
now.addSeconds(second); // Adds some seconds into now variable
return now.getDisplayValue(); //Returns the Date/Time of right now.
},
type: 'ClientDateTimeUtils'
});

 

Client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

if (isLoading || newValue === '') {
return;
}

if (newValue == '1'){
var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name','getNowDateTimePlus14');
ajax.addParam('sysparm_addDays',14);
ajax.addParam('sysparm_addSeconds',0);
ajax.getXML(doSomething);

}
function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_on_hold_reminder', answer);
}
}

 

Scripts are working fine but I am still receiving error message posted bellow:

find_real_file.png

 

Do you have any idea where can be problem?

Thanks in advance,

Ondrej

 

 

4 REPLIES 4

Michael Fry1
Kilo Patron

Try updating this line: var now = new GlideDateTime(); // Sets current time to now variable

to this: var now = new GlideDateTime().getDisplayValue(); // Sets current time to now variable

Hello Michael,

thanks for recommendation. But unfortunately it returns same error 😞

 

 

Abbas7
Tera Contributor

Seems fine i tried at my instance should not give you this error, just check if you have created it in global application... 🙂

 

Thanks. Finally I found that client script was wrongly configured.