The CreatorCon Call for Content is officially open! Get started here.

How to call script include from UI Page client script section ?

fisfreak
Kilo Contributor

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

 

20 REPLIES 20

Hi,

After adding that in the UI, I got that error

So i have already included that in the UI Page

So does it not work at all if you remove the UI script reference from the UI page?

Shivaji Varma
ServiceNow Employee
ServiceNow Employee

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.


Trupti6
Tera Expert

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/

fisfreak
Kilo Contributor

Hi tripti,

what is wrong with my code here.

find_real_file.png

Comment on my above code, let me know if you see any mistake.

You can also go through the conversation between me and Gaurav if you want to, because i have done almost everything that is possible.

 

Thanks,

Krishna P