GlideAjax / application scopes

mathieu_brule
Kilo Sage

Hi everyone !

I'm actually facing an issue, I really can't understand : I'm trying to call a script include with Glide Ajax, but it doesn't work... I'm in a catalog client script, set in Customer Service application scope, which calls a script include, in global application, set on Accessible for all.

To make it simplier to analyse, my script include just returns "test" value :

My catalog client script (CustomerService application) :

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

    var ga = new GlideAjax('global.Test');
    ga.addParam('sysparm_name', 'testMethod');
   
    ga.getXML(function(response) {
		var test = response.responseXML.documentElement.getAttribute("answer");
        alert("test " + test);
    });
}

My script include (global and accessible from All application scope) :

var Test = Class.create();
Test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	
	testMethod : function() {
		return "test";
	},

	type: 'Test'
});

 

My alert message, in my callback function, returns ... null...

 

Could anyone explain me what's happening ?

8 REPLIES 8

Aman Kumar S
Kilo Patron

It should work:

Try changing your client script to:

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

    var ga = new GlideAjax('global.Test');
    ga.addParam('sysparm_name', 'testMethod');
   
    ga.getXML(callBack);

    function callBack(response){
        var test = response.responseXML.documentElement.getAttribute("answer");
        alert("test " + test);
    });
}

 

For more details, feel free to explore:

https://community.servicenow.com/community?id=community_blog&sys_id=788c66e1dbd0dbc01dcaf3231f961969

Best Regards
Aman Kumar

Hi,

 

Thanks for your answer, but it doesn't work 😞

I had implemented like this at beginning of my tests.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

that means script include is not getting called

Is script include client callable?

share your screenshots for both the configurations script include and client script

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Yes, it is client callable.

To be sure it's all right, I've made an insert&stay on a OOB script include, which I was able to make work.

But unable to call the copy, whereas the OOB works 😞