GlideAjax not calling Script Include

Mahesh_Krishnan
Giga Guru

Hello All:

I am not sure what is missing in my code but it does not appear that the client ajax is calling my script include as the gs.info message is not getting logged. Attached are my client and server scripts.

Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue === '') {
        return;
    }
   
    var ga = new GlideAjax('Validate_OSN');
    ga.addParam('sysparm_name', 'getOSN');
    ga.addParam('sysparm_OSN', g_form.getValue("osn"));
    ga.getXMLAnswer(function(answer) {
        if (!answer == g_form.getValue("osn")) {
            g_form.showFieldMsg('osn', getMessage('Invalid OSN'), 'error', false);
        } else {
            return;
        }
    });
}



Script Include:

var Validate_OSN = Class.create();
Validate_OSN.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

    getOSN: function() {
        var inputOSN = this.getparamater('sysparm_OSN');
		
	gs.info("Code called from client " + inputOSN );

}

I have included only a small portion of the script include as I was just trying to see if it is even being called by the client script, by inserting a gs.info line and then seeing in the System log for that message. 

Even after multiple attempts I am not seeing the message in the system log and so infer that the server script is not being invoked.

Appreciate any assistance from the grouop!

Mahesh

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hello,

Please ensure the appropriate onChange field is being used and the client script in active.

Please ensure the script include has the client checkbox checked (we se the Ajax processor in your SI, but you could have set the checkbox to false after writing the SI)

Please ensure that you use the appropriate scope in the Ajax call if they are not in the same scope and ensure that the SI has appropriate accessibility set for it to allow other scopes access.

Also, you have typo here?

this.getparamater

Capital P and the spelling is wrong...

this.getParameter

Please refer to documentation for proper formatting, etc. https://docs.servicenow.com/bundle/quebec-application-development/page/script/ajax/topic/p_AJAX.html

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


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

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

Hello,

Please ensure the appropriate onChange field is being used and the client script in active.

Please ensure the script include has the client checkbox checked (we se the Ajax processor in your SI, but you could have set the checkbox to false after writing the SI)

Please ensure that you use the appropriate scope in the Ajax call if they are not in the same scope and ensure that the SI has appropriate accessibility set for it to allow other scopes access.

Also, you have typo here?

this.getparamater

Capital P and the spelling is wrong...

this.getParameter

Please refer to documentation for proper formatting, etc. https://docs.servicenow.com/bundle/quebec-application-development/page/script/ajax/topic/p_AJAX.html

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


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

Mahesh_Krishnan
Giga Guru

It was the spelling error...staring at your own code for awhile does not help!! Thanks a bunch Allen!!

Tony Chatfield1
Kilo Patron

Hi, unfortunately your post doesn't provide any details regarding your overall configuration\settings
Dos this run against a custom table, is is global scope, have you flagged the script-include as client callable? Also the script - include formatting above is incorrect, but this could be a result of you pasting partial code into your post?

The most probable issue is the incorrect syntax in the script-include for 'this.getparamater'
it needs to be this.getParameter

Otherwise testing in a PDI using incident and impact\urgency fields it appears to function as it was written.