how to use client script and ui policy on service portal?

Sona1
Kilo Contributor

I have catalog item named asset relocation

this catalog item is used to relocate the asset from one location to other. in this cat item when u select any item it will automatically populates its current location in current location field. for this I hv used reference variable "curr_location" and ui policy to find the location from location table

I want this to work in service portal. but in service portal it is not auto populating the current location of item

15 REPLIES 15

Sona1
Kilo Contributor

Thanks Jesse.


can you help me with following script?


Capture3.PNG


jesseadams
ServiceNow Employee
ServiceNow Employee

Hey Sona,


It looks like the problem is the getXMLWait().


In service portal you have to use asynchronous ajax.


Try moving the code to set the value into a function and then call ga.getXML(yourFunction())


Check out this example from the developer docs for the exact syntax: AJAX but it would be something like this:



.. your glideAjax code..


ga.getXML(callback);



function callback(response){


g_form.setValue("curr_location",answer);


}


Sona1
Kilo Contributor

Thanks Jesse.


It is still not working


Capture5.PNG


Capture6.PNG


jesseadams
ServiceNow Employee
ServiceNow Employee

Ah, sorry, I mixed up the variable name. g_form.setValue("curr_location",answer); should have been g_form.setValue("curr_location",response);



Sona1
Kilo Contributor

Thanks Jesse.


All these codes are working properly in service catalog (native).


But it is not working in Service portal.


Is it related to the concept that client script and UI policy does not apply in service portal?