- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 02:19 PM
Hello,
I have a record producer with an onChange catalog client script. The catalog client script is using a glideAjax call to call my script include function. For some reason though it seems my function in the script include is never getting executed. I have minimalized the function as much as possible just to see if I can write to the log in the script include function, but I am getting nothing. I have verified that my naming and spelling of variables is correct. Does anyone see what I am doing wrong here?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 05:01 PM
Hi Jared,
Try the following scripts. Executing these script should pop-up an alert with message 'OK'.
Things I've fixed:
- Set argument of process to 'answer'
- Directly output without using parsing because .getXMLAnswer() will return a string and not a xml. This implies there's no "answer[0]" nor "answer[1]" because answer is a String and not an array.
- Delete "initialize: function() {}," in Script Include. There's no initialize when it's Client Callable.
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var adapiCall = new GlideAjax('ADAPICall');
adapiCall.addParam('sysparm_name', 'getGroups');
adapiCall.getXMLAnswer(process);
function process(answer) {
alert(answer);
}
}
Script Include
var ADAPICall = Class.create();
ADAPICall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function() {
return 'OK';
},
type: 'ADAPICall'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 02:39 PM
Hi Jared,
so how does your script include function looks like?
Looking at the script include name, can this be an ACL issue? (are you testing it under admin account?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 02:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 07:21 PM
A Script Include meant to be called through GlideAjax, extending AbstractAjaxProcessor must not have an initialize() member. Or if it has one it has to call the initialize member of AbstractAjaxProcessor.prototype. The initialize member of the AbstractAjaxProcessor.prototype contains critical variable assignments that are overwritten and cancelled by the initialize member of your class.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 05:01 PM
Hi Jared,
Try the following scripts. Executing these script should pop-up an alert with message 'OK'.
Things I've fixed:
- Set argument of process to 'answer'
- Directly output without using parsing because .getXMLAnswer() will return a string and not a xml. This implies there's no "answer[0]" nor "answer[1]" because answer is a String and not an array.
- Delete "initialize: function() {}," in Script Include. There's no initialize when it's Client Callable.
Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var adapiCall = new GlideAjax('ADAPICall');
adapiCall.addParam('sysparm_name', 'getGroups');
adapiCall.getXMLAnswer(process);
function process(answer) {
alert(answer);
}
}
Script Include
var ADAPICall = Class.create();
ADAPICall.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroups: function() {
return 'OK';
},
type: 'ADAPICall'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 03:13 AM
When switching from a normal Script Include to a client callable, the script content is kept. This means the function initialize is kept too.
Be sure to remove this function in order to be able to call the Script Include via GlideAjax.