Jelly Script get Parameter from URL

rad2
Mega Sage

Hello,

I am trying to get parameter from the URL in UI pages.

URL - https://xxxxxx.service-now.com/incident.do?sys_id=-1&sys_is_list=true&sys_is_related_list=true&sys_target=incident

I have tried the below code

<g:evaluate var="jvar_sys">
    var sysparm_id = RP.getParameterValue("sys_target") + "";
    sysparm_id;
</g:evaluate>


<span>${jvar_sys}</span>

 

This works when i try to get sys_id but returns blank when used for sys_target

Is there any way to get it work for other parameters?

 

1 ACCEPTED SOLUTION

Hi,

then this should work fine

<g:evaluate var="jvar_sys" jelly="true" object="true">
    var sysparm_id = gs.action.getGlideURI().getMap().get('sys_target');
    sysparm_id;
</g:evaluate>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

-O-
Kilo Patron
Kilo Patron

Accessing a parameter in a UI Page is as simple as:

$[ <parameter name> ]

that is

$[ sys_target ]

However be careful how you test it. You should be loading page <ui_page_name.do?...> not ui_page.do?sys_id=.... The latter is actually calling your UI Page indirectly, through the UI Page processor and in that case it will not work.

Which brings me to my next question: your original post mentions incident.do. Is that just an example, or otherwise what is the real use case, cause that displays incidents, of course.