GlideDateTime is not defined function error on client script populated field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 07:31 AM
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:
Do you have any idea where can be problem?
Thanks in advance,
Ondrej

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2018 09:21 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 12:13 AM
Hello Michael,
thanks for recommendation. But unfortunately it returns same error 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 12:36 AM
Seems fine i tried at my instance should not give you this error, just check if you have created it in global application... 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2018 03:05 AM