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

gauravchoudhury
Tera Guru

Hi Sona,



You need to select the Run Script in UI type as 'Both' to make it work on the portal. Same applies for catalog clients script as those will also not work if its UI type is not selected as 'Both'.



find_real_file.png



If this still doesn't solve your query, then please confirm which version of ServiceNow are you working this out on.



Previous discussions about this issue were flagged by many users but it was later fixed from Helsinki Patch 5 and onwards.



Your last resort would be to check with HI Support and report this issue for them to investigate.


Thanks Gaurav.


i am using following script


Capture1.PNGCapture2.PNG


Capture3.PNGCapture4.PNG


Hi Gaurav,
I have a similar issue. One of my cat.items has a ui policy and that policy does work on the UI but not in the portal. I have set the ui type on both but do not know what script text I should add then.
I have added some screenshots here as well for more explanation. Hopefully helpful in answering my question.
By the way... I'm running on Jakarta.


view in UI


role editable.PNG


view in portal


role not editable.PNG


catalog client script role choice.PNG



Can you guide me in the right directions to make the role field editable in portal as well?


jesseadams
ServiceNow Employee
ServiceNow Employee

Hey Sona,


In addition to making sure your scripts are set to run in both mobile and desktop, make sure you are using only mobile compatible APIs.


For example, if you're using client side GlideRecord or some GlideAjax script to get referenced record or location those calls have to be asynchronous and use a callback function in order to work in service portal.



Here's a more comprehensive list of what client side scripting methods are supported for service portal. Check and make sure you're not using any APIs that aren't included in the list:


https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/reference/s...