How to access a record's URL in UI Action

ywen
Kilo Contributor

We have a requirement of conditional logic in a UI Action.   I'm trying to pass in the application state via a custom query parameter in the record's URL.   For example the portalmode parameter below:   (blahs in place of sys id)

/sysapproval_approver.do?portalmode=yes&sysparm_view=ess&sys_id=blahblah

However when I use gs.action.getGlideURI() (following this solution https://servicenow-pub.hosted.jivesoftware.com/thread/222681 ) in the UI Action script, the string I get back does not match the parameters I passed to the record.   I'm getting back sysparm_tiny=blahblahblah

What am I doing wrong?   Thanks

5 REPLIES 5

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Yang,



You may find the below link helpful.


3 Ways to Populate Values in ServiceNow via the URL


THanks for the link.   However that article doesn't cover the use case I'm inquiring.



I want to pass in some arbitrary parameter when loading a record.   This arbitrary parameter is not necessarily an actual field on the record I'm loading. I would like for the UI Action script to be able to check for that parameter's value so I can execute conditional code.


Hi Yang,



Here's something to try...



var uri = action.getGlideURI();


var map = uri.getMap();



map contains an object full of details on the record, including URI parameters (e.g. sysparm_view=ess).


It would appear that your URL with parameters was longer than the property glide.tiny_url_min_length specified and so a tiny URL was generated and that's what you have access to. You could test this by increasing the value of glide.tiny_url_min_length or by setting glide.use_tiny_urls to false and see if you can get properties from the URL. Hopefully this gets you closer to a solution.