Unable to set value to a Catalog Item Variable in Service Portal

reginabautista
Kilo Sage

Hi everyone,

I am trying to set a value to a catalog item variable via Catalog Client Scripts. It is working if being loaded in native UI but when opening in Service Portal the value is not being set. I'm really baffled at this. Anyone know why? Thanks - Regina

Here's the code (onLoad):

        g_form.setValue('variables.url', 'test');

Native UI:

find_real_file.png

Service Portal:

find_real_file.png

1 ACCEPTED SOLUTION

Hmm...could you post your entire client script? Also, make sure you have UI Type marked as Both on the catalog client script record itself.


View solution in original post

10 REPLIES 10

Hmm...could you post your entire client script? Also, make sure you have UI Type marked as Both on the catalog client script record itself.


Is the Service Portal widget rendering the Catalog Item considered "Mobile"?



What is a good method to detect a client script is being evaluated in the Service Portal?



So far, I have been using if(window === null).



Thanks,



John G



Using documentation/client_scripting.md at master · service-portal/documentation · GitHub   as reference doc.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi John,



That should work. It's not necessarily considered mobile as much as they have similar APIs available. window is blocked in Service Portal so it's a good way to check.


Hi Brad,



Ok, cool. I wanted to make sure there was not some special method/object similar to g_service_catalog available to determine Service Portal evaluation.



Thanks!



John


reginabautista
Kilo Sage

Hi Brad, removing the "variables" from the setvalue AND setting the UI Type to "Both" did the trick. Thank you so much!