GlideAjax returning null

Kingstan M
Kilo Sage

Hi SNC,

GlideAjax returning null value.

Where i am doing wrong?

Script Include 

    checkTheExisingPachingRequest: function(AppServiceId, reqStartDate, reqEndDate) {
        
        var appserviceId = this.getParameter('sysparm_Appci') || AppServiceId;
        var sDate = this.getParameter('sysparm_reqStartDate') || reqStartDate;
        var eDate = this.getParameter('sysparm_reqEndDate') || reqEndDate;

        gs.log("appserviceId >> " + appserviceId);
        gs.log("sDate >> " + sDate);
        gs.log("eDate >> " + eDate);

Catalog Client Script

function onSubmit() {
    //Type appropriate comment here, and begin script below

    // >> topic >> getting boolen value server_patching_request
    var server_patching_request_true_or_false = g_form.getValue('server_patching_request');
    var application_choosen = g_form.getValue('application_service');
    var start_time_choosen = g_form.getValue('start_timestamp');
    var end_time_choosen = g_form.getValue('end_timestamp');

    //alert(server_patching_request_true_or_false + " >> " + g_form.getValue('application_service') + " >> " + g_form.getValue('start_timestamp') + " >> " + g_form.getValue('end_timestamp'));

    // >> topic >> initiate GlideAjax and pass the above values
    var gjx = new GlideAjax('WOWserverbookerUtils');
    gjx.addParam('sysparm_name', 'checkTheExisingPachingRequest');
    gjx.addParam('sysparm_Appci', application_choosen);
    gjx.addParam('sysparm_reqStartDate', start_time_choosen);
    gjx.addParam('sysparm_reqEndDate', end_time_choosen);
    gjx.getXML(CallBack);
    alert(JSON.stringify(gjx));

    function CallBack(response) {
        var output = response.responseXML.documentElement.getAttribute("answer");
        alert(output);
    }


}

1 ACCEPTED SOLUTION

Update the below line as below and try.

var arrAppServiceID = appserviceId.toString().split(',');

Replaced "AppServiceId" with "appServiceId".

 

Regards,
Muhammad

View solution in original post

17 REPLIES 17

MrMuhammad
Giga Sage

HI,

I can see you are not returning anything from script include back to client script. So please return any value may be something like below

checkTheExisingPachingRequest: function(AppServiceId, reqStartDate, reqEndDate) {
        
        var appserviceId = this.getParameter('sysparm_Appci') || AppServiceId;
        var sDate = this.getParameter('sysparm_reqStartDate') || reqStartDate;
        var eDate = this.getParameter('sysparm_reqEndDate') || reqEndDate;

        gs.log("appserviceId >> " + appserviceId);
        gs.log("sDate >> " + sDate);
        gs.log("eDate >> " + eDate);
        
        return appserviceId;
}

 

After logs I'm returning appserviceId. If that still gives you null then confirm the below

1. Client callable is checked on the script include? 

2. If this is scoped app then please use Script include API name (field below name) in the GlideAjax instead of Script include name.

3. Further, what you are getting in the logs that you have placed inside the script incude?

Please mark this helpful/correct, if applicable.

Regards,

Muhammad

Regards,
Muhammad

Script include is quite long one BUT i do return at the end of the function.

Script Include works fine when i test it via background script anyway!!

Have you confirm that the script is marked as client callable?

Regards,
Muhammad

client callable = checked

logs in script include returns value when i test from background script.

but it returns nothing when i try with catalog client script via GlideAjax.

but the values in GlideAjax i can see in alert that values are captured.