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

Update the below line as below and try.

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

Replaced "AppServiceId" with "appServiceId".

 

Regards,
Muhammad

Yes, This is the bug. Thanks.

Educate me, What made you to spot this as an err?

Because when i try the same in bg.script --like below-- it all worked fine. But not via catalog client script.

var obj = new WOWserverbookerUtils();
gs.info(obj.checkTheExisingPachingRequest('<<app_sys_id>>','28-08-2022 02:30 AM','28-08-2022 05:30 PM'));

"AppServiceId" is a function parameter that is passed when the call is made from server side script just like you scripted above.

When you are calling it from the client script you are not passing "AppServiceId" instead you are passing as "sysparm_Appci". So "AppServiceId" is empty when the call is being made by the client script.

The reason of using "appserviceId" is that it contains either "AppServiceId" or "sysparm_Appci".

Regards,
Muhammad