Cannot call script include from client script

Francis
Mega Expert

Hi fellow service-now developers,

I am trying to call a "Script Include" from a "Client script", but I cannot make it works.

Client script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var ga = new GlideAjax('VdlAddressUtils');
    ga.addParam('sysparm_name', 'hasIdGDA');
    ga.getXML(getResponse);

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

 

Script include:

var VdlAddressUtils = Class.create();
VdlAddressUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    hasIdGDA: function() {
        return "1";
    },
    type: 'VdlAddressUtils'
});

Do you know why?

 

PS: My script include is accessible remotely.

PS2: My alert shows a "Null".

 

Edit: After the suggestion of @Aman Kumar, I added a gs.info into my script include and I did get a log.

1 ACCEPTED SOLUTION

Francis
Mega Expert

Ok, got it guys.

I had a "gs.log("!!!HERE!!");" into my script include, and that causes my issue.

 

Thank you all!

View solution in original post

11 REPLIES 11

Allen Andreas
Administrator
Administrator

Hi,

Please use the appropriate forum feature: "Insert/Edit code sample" when pasting code on the forums. Currently, your formatting is all off and confusing.

find_real_file.png

Additionally, please refer to this GlideAjax cheat sheet for a quick summary of how to format things: https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

Unfortunately, you haven't told us much as far as any troubleshooting you've done, errors you're seeing, etc.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

My bad, I just updated it. Didn't expect a response that fast ^^

Hello,

I'm glad my reply above was at least Helpful.

The script you provided showed no logging, which is why I was asking about it above. Now, you've marked your own reply as Correct due to gs.log (which you shouldn't use anyway -- use gs.info()

Oddly, there was quite a bit of responses here...in the future, I hope you provide more information. Thanks!

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Aman Kumar S
Kilo Patron

Hey

Try putting gs.info statement in your function to see if the client script is even calling the Script include also

when you put alert, there is no semi-colon

 

alert(res);

 

Best Regards
Aman Kumar