Calling script include from UI Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 06:05 AM
Hi Everyone,
I am calling script include from UI Script. The script include is client callable and I placed gs.info in start of script include, but I cannot see gs.info in logs.
UI Script:
alert('This is test message');
var ar = new GlideAjax('x_cc_aa.myScriptInclude');
ar.addParam('sysparm_name', 'setDetails');
ar.addParam('sysparm_sysID', 'ed92e8d173d023002728660c4cf6a7bc');
ar.addParam('sysparm_table', 'incident');
ar.addParam('sysparm_contact_sysID', '77ad8176731313005754660c4cf6a7de');
ar.getXMLAnswer(setURLCallback);
function setURLCallback(response) {
alert(response);
var params = 'scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=1000,height=550,left=180,top=100';
var newWin = top.window.open(response, '_blank', params);
newWin.opener = null;
}
Script Include:
var myScriptInclude = Class.create();
myScriptInclude .prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
setDetails: function() {
var callUrl = "https://www.google.com/"
return callUrl;
},
type: 'myScriptInclude '
});
Can we call script include into UI Script.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 09:05 AM
okay got it.
In this case then unless your UI script function is invoked by some client side code, it won't call the Ajax function.
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-27-2025 06:39 AM
Hello @Abhijit Das7 ,
Your Script Include and UI Script work fine on my instance.
- Have you checked the "Global" checkbox of the UI Script?
- What is the UI type selected? Are you using that UI type while testing?
- Have you verified that the Script Include is in the "x_cc_aa" scope?
- If the UI Script is in a different scope: what are the "Accessible from" and "Caller access" settings on the Script Include?
- Also, reload any page (if the UI Script is Global) and open your browser console. Log for the "Batched GlideAjax: Got response" line and provide the response text.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 06:48 AM
Hi @Robert H ,
- UI Script is in scoped application and even script include is in same application.
- UI type is "Desktop".
- Yes, script include is in same scope.
- UI script and script include are in same scope. "Accessible from" and "Caller access" are "All Application scopes" and "none" respectively.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 06:52 AM
Hello @Abhijit Das7 ,
Ok, thanks. Can you also please answer the first question (is the UI Script set as "Global")?
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2025 06:56 AM
Hi @Robert H ,
While creating UI Script in scoped application, I did not get "global" checkbox. That means UI script is not global.
Regards