GlideDate() is working in client Script, however the requirements should be in GlideDateTime (). Is there anyone who can assist me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 12:12 AM
var recPriority = g_form.getValue('u_rec_rating');
var cdt = new Date(); // When I use GlideDateTime() it's showing error.
var addtime;
var addtype = 'day';
if (recPriority == '2') {
addtime = 7; //The amount of time to add
}
if (recPriority == '3' || recPriority == '4') {
addtime = 90; //The amount of time to add
}
var ajax = new GlideAjax('global.ClientDateTimeUtils');
ajax.addParam('sysparm_name', 'addDateAmount');
ajax.addParam('sysparm_fdt', cdt);
ajax.addParam('sysparm_addtime', addtime);
ajax.addParam('sysparm_addtype', addtype);
ajax.getXML(doSomething); //Need callback function
function doSomething(response) {
//Sets field
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('due_date', answer);
Current Result:
Expected : DateTime

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 12:18 AM
Hi,
Why don't you use GlideDateTime in Script include function. Instead of passing parameter from Client script, you can skip it and use GlideDateTime API in script include function for calculations.
Thanks
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 01:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 12:39 AM
Hi Ashoka,
refer below code in your script include
check_probation: function() {
var prob = this.getParameter('sysparm_value'); // to get parameter from client side in your case recPriority
var today = new GlideDateTime();
if (prob == 'true') {
today.setDisplayValue(today.addDays(30));
}
if (prob == 'false') {
today.setDisplayValue(today.addDays(90));
}
return today.getDisplayValue();
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2022 01:15 AM
Hi Ashoka,
Can you share your script include as well ?