- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 04:07 AM
Dear All,
I have this Script Include (Client callable):
var SimpleExampleScriptInclude = Class.create();
SimpleExampleScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMessage: function () {
return 'Hello from the Script Include!'; // Simple response
}
});
And I have this Catalog Client Script (UI Type is: 'All'):
function onLoad() {
// Create a GlideAjax object and specify the Script Include
var myGlideAjax = new GlideAjax('SimpleExampleScriptInclude');
// Add the name of the method to call in the Script Include
myGlideAjax.addParam('sysparm_name', 'getMessage');
// Execute the GlideAjax call
myGlideAjax.getXMLAnswer(function(response) {
if (response) {
// Set the field value with the returned response
g_form.setValue('test_string_field', response);
} else {
// Handle cases where no response is returned
g_form.setValue('test_string_field', 'No message returned');
}
});
}
It works on the Platform, because the value of the 'test_string_field' goes to 'Hello from the Script Include!' (the message from the Script Include).
However it does NOT work on the Portal, because the value of the 'test_string_field' goes to '
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 05:17 AM
It's unable to call that script include from portal.
script include and client script both are in same scope or different ones?
Try with fresh client script and script include
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 04:20 AM
what came in response? did you add alert?
change the function name for script include and see
getMessage() is OOTB method and may be it is colliding.
function onLoad() {
// Create a GlideAjax object and specify the Script Include
var myGlideAjax = new GlideAjax('SimpleExampleScriptInclude');
// Add the name of the method to call in the Script Include
myGlideAjax.addParam('sysparm_name', 'getMessage1');
// Execute the GlideAjax call
myGlideAjax.getXMLAnswer(function(response) {
alert('response is' + response);
if (response) {
// Set the field value with the returned response
g_form.setValue('test_string_field', response);
} else {
// Handle cases where no response is returned
g_form.setValue('test_string_field', 'No message returned');
}
});
}
Script include:
var SimpleExampleScriptInclude = Class.create();
SimpleExampleScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMessage1: function () {
return 'Hello from the Script Include!'; // Simple response
}
});
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 04:38 AM
- Can you put some log in script include before the return statement and check if it is getting triggered
- If the log is triggered in script include then print the response in client script before setting the value.
This way you will first find where is it broken.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 05:11 AM
Hi,
Script Include updated:
var SimpleExampleScriptInclude = Class.create();
SimpleExampleScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMessage1: function () {
gs.info("Script include triggered!");
return 'Hello from the Script Include!';
}
});
When loading the Catalog Item on the Platform:
Information is logged in the syslog table successfully.
When loading the Catalog Item on the Service Portal:
These appear in the browser console:
Error: Unhandled exception in GlideAjax.
Warning: getMessage (key="Quantity {0}"): synchronous use not supported in Mobile or Service Portal unless message is already cached
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2025 04:43 AM
Thank you @Ankur Bawiskar for the reply.
However, it does not work with getMessage1 as well. ☹️
This is the browser error message, when Portal is loaded:
getMessage (key="Quantity {0}"): synchronous use not supported in Mobile or Service Portal unless message is already cached
This error message does not show on the Platform.
Can you please perhaps help?
Regards,
Gergely