- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 12:47 AM
Hi Community,
I'm trying to call a script include from a catalog client script, but it doesn't work.
Some trials to investigate the cause and the results:
1. I changed the contents of the scripts to something very simple to investigate the cause, but the result is not returned.
2. I'm trying to spit out logs in the script include, but I don't see any logs. (Other script includes display the log, so you don't need to troubleshoot that part.)
3. The catalog client script itself is working fine, and "g_form.addInfoMessage" shows that null is returned from the script include.
Can anyone tell me what's wrong or detailed troubleshooting steps?
The following are the set values:
<Catalog Client Scripts>
Applies to: A Catalog Item
Active: True
UI Type: Mobile / Service Portal (The result is the same even if it is All)
Application: Global
Type: onChange
Applies on a Catalog Item view: True
<Script Include>
Name: getCurrentOperationSchedule
Application: Global
Accessible from: All application scopes
Client callable: True
Active: True
Protection policy: None
Below is the content of the scripts:
<Catalog Client Scripts>
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// var selectedWork = g_form.getValue('regular_work'); //commented out for investigation
var ajax = new GlideAjax('getCurrentOperationSchedule');
ajax.addParam('sysparm_name', 'showSchedule');
// ajax.addParam('sysparm_work', selectedWork); //commented out for investigation
ajax.getXML(displaySchedule);
function displaySchedule(response) {
var currentSchedule = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage('The value is'+ currentSchedule); //returned message: The value is null
}
}
<Script Include>
var getCurrentOperationSchedule = Class.create();
getCurrentOperationSchedule.prototype = Object.extendsObject(AbstractAjaxProcessor, {
showSchedule: function() {
gs.info('Script Include getCurrentOperationSchedule Started');
// var selectedWork = this.getParameter('sysparm_work'); //commented out for investigation
return 'test';
},
type: 'getCurrentOperationSchedule'
});
I'm new to ServiceNow and JavaScript, so I expect easy-to-understand comments.
Thanks in advance,
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 06:41 PM
As you're on San Diego, client callable ACLs are created. Are you testing your script include as an admin or by impersonating a user?
Has the necessary ACL been created with a name of getCurrentOperationSchedule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 12:54 AM
Hello
in the client script try to put the API name of the script include instead of calling it via name
Go to your script include and you will find the API name field ,copy it and paste it in glide ajax and give it a try .
var ajax = new GlideAjax('your_Script_include_api_name');
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 01:21 AM
Hello
Thanks for quick reply.
I tried changing the settings to the following but unfortunately the result was the same.
var ajax = new GlideAjax('global.getCurrentOperationSchedule');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 01:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2022 01:51 AM