How to call script include from UI Page client script section ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 02:50 AM
Hello,
I need to make a call to script include from UI Page, when i try to invoke a function from client script of UI Page, it is not returning me anything, where as same thing works from catalog client script. please find the code snippet below.
$(document).ready(function() {
var ga = new GlideAjax("ControlVirtualMachinesAjax");
ga.addParam("sysparm_name", "getVMSInRG");
ga.getXML(ajaxResponse);
function ajaxResponse(serverResponse) {
alert("ServerResponse: " + serverResponse);
}
});
Same code works perfect from catalog client script but not from client script of UI Page. In the above code , control never comes inside ajaxResponse method.
Thanks,
Krishna P
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 04:37 AM
Hi,
After adding that in the UI, I got that error
So i have already included that in the UI Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 04:44 AM
So does it not work at all if you remove the UI script reference from the UI page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2018 03:33 AM
Have you tried placing `debugger;` and open browser console and check for execution of client script?
Also '$' may not be referring to jQuery on UI page. As Gaurav said remove $(document).ready check, as it is not required.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 05:08 AM
Hi,
While you can call script includes from the HTML in a UI page, it's not a direct call. In order to call a script include you need to use 'GlideAjax' from a client script (which can be called from the HTML).
Here's some information on GlideAjax...
http://wiki.service-now.com/index.php?title=GlideAjax
And here's an example of how you can use it from a UI page...
http://www.servicenowguru.com/system-ui/ui-actions-system-ui/creating-custom-slushbucket-popup-dialog/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2018 05:29 AM