Client callable script include is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 05:59 AM
Client Script Code -
function onLoad() {
// Initialize GlideAjax with the 'callerUtilsAjax' processor
var ga = new GlideAjax("callerUtilsAjax");
ga.addParam("sysparm_name", 'getName');
ga.addParam("sysparm_caller", 'Prithvi Ramesh');
ga.getXMLAnswer(function(response) {
if (response) {
alert(response);
} else {
alert("No response received from the server.");
}
});
}
Script Include -
var callerUtilsAjax = Class.create();
callerUtilsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
// Method to get the caller's name and return a welcome message
getName: function() {
var name = this.getParameter('sysparm_caller'); // Retrieve the 'sysparm_caller'
gs.log("Welcome " + name + " !");
return "Welcome " + name + " !"; // Return a welcome message
},
type: 'callerUtilsAjax' // Define the type of the processor
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 06:24 AM
Is the Script Include in the same scope as the Catalog Item / Client Script? Is there a role required to access the script, defined on the Script Include related list?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 06:27 AM
is the script include and client script in same scope?
Don't use gs.log() as it will break in scoped app
is the client callable checkbox marked as True?
are you testing with non-admin or admin?
if non-admin and it's not working then what role does that user have "snc_external"?
If yes then try adding this isPublic function in script include
var callerUtilsAjax = Class.create();
callerUtilsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic: function() {
return true;
},
// Method to get the caller's name and return a welcome message
getName: function() {
var name = this.getParameter('sysparm_caller'); // Retrieve the 'sysparm_caller'
gs.info("Welcome " + name + " !");
return "Welcome " + name + " !"; // Return a welcome message
},
type: 'callerUtilsAjax' // Define the type of the processor
});
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader