Script include returning NULL to Client script

Omkar Jori
Tera Expert

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.

1 ACCEPTED SOLUTION

Omkar Jori
Tera Expert

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);​

 

 

View solution in original post

5 REPLIES 5

Omkar Jori
Tera Expert

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);​