- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 07:08 PM
Hello,
I have created a script include to check if the date entered is in scheule or not, but the script include is returning value as Null.
Please check the below script
Script include:
var execution_date_check = Class.create();
execution_date_check.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
isPublic: function() {
return true;
},
scheduleCheck: function() {
var execution_date = this.getParameter('execution_date');
execution_date = new GlideDateTime(this.execution_date.getDisplayValue());
var flag;
var scheduleID_holidays = new GlideSchedule("755bc0091ba908107a44fd14cc4bcb0d");
if(scheduleID_holidays.isInSchedule(execution_date)) {
flag = true;
}
else {
flag = false;
}
return flag;
},
type: 'execution_date_check'
});
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var execution_date = g_form.getValue("u_execution_date_and_time");
var dateTime = execution_date.split(' ');
var date = dateTime[0];
var answer = "";
var ga = new GlideAjax('sn_customerservice.execution_date_check'); //Scriptinclude
ga.addParam('sysparm_name', 'scheduleCheck'); //Method
ga.addParam('execution_date', date); //Parameters
ga.getXML(HelloWorld);
function HelloWorld(response) {
answer = response.responseXML.documentElement.getAttribute('answer');
alert(" answer : " + answer);
}
}
Both the client script and script include are in Customer service scope and Client callable is enabled in Script include.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 08:11 PM
I got the solution, as I removed the .getDisplayValue() and it worked.
execution_date = new GlideDateTime(execution_date.getDisplayValue());
After change
execution_date = new GlideDateTime(execution_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 07:24 PM
Have you checked your system logs for any errors within your client script, for example, you're using this.execution_date which isn't a property of your script include and may be causing your script to fail:
execution_date = new GlideDateTime(execution_date.getDisplayValue()); // removed: `this.`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 07:27 PM
Hi @Nick Parsons ,
Thank you for your reply.
I tried removing this but getting the same Null in the alert.
Nothing is generating in system logs.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 07:45 PM
@Omkar Jori Could you please update your client script and script include as follows and see if it works.
var execution_date_check = Class.create();
execution_date_check.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
isPublic: function() {
return true;
},
scheduleCheck: function() {
var execution_date = this.getParameter('sysparm_execution_date');
execution_date = new GlideDateTime(this.execution_date.getDisplayValue());
var flag;
var scheduleID_holidays = new GlideSchedule("755bc0091ba908107a44fd14cc4bcb0d");
if(scheduleID_holidays.isInSchedule(execution_date)) {
flag = true;
}
else {
flag = false;
}
return flag;
},
type: 'execution_date_check'
});
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var execution_date = g_form.getValue("u_execution_date_and_time");
var dateTime = execution_date.split(' ');
var date = dateTime[0];
var answer = "";
var ga = new GlideAjax('sn_customerservice.execution_date_check'); //Scriptinclude
ga.addParam('sysparm_name', 'scheduleCheck'); //Method
ga.addParam('sysparm_execution_date', date); //Parameters
ga.getXML(HelloWorld);
function HelloWorld(response) {
answer = response.responseXML.documentElement.getAttribute('answer');
alert(" answer : " + answer);
}
}
Root cause: You forgot to add sysparm_ suffix before execution_date parameter in client script and script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2024 08:01 PM
Hi @Sandeep Rajput ,
I did tried adding the sysparm, but no luck.
I understood that there is issue with the date format which I am passing and checking in the script include.
Please help if you notice anything