Get paramter sysparm_query from URL using jelly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 11:08 AM
I want to get the sysparm_query value from this url: nav_to.do?uri=/ui_page.do%3Fsys_id%3D222a312fdbb9220065dfd001cf96191e%26sysparm_query%3Dstate%253D1
by using jelly. I used:
<j:set var="jvar_query" value="${sysparm_query}" />
and
<j:set var="jvar_query" value="${RP.getParameterValue('sysparm_query')}" />
In both cases I can't get the value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-24-2016 07:35 AM
Hi Chuck,
if i trigger the ui page from the header list - > the URL is following: ui_page.do?sys_id=222a312fdbb9220065dfd001cf96191e&sysparm_query=state%3D1.
I have access to the sys_id but sysparm_query stays always empty.
My Context Menu:
runContextAction();
function runContextAction() {
var url = new GlideURL('ui_page.do?sys_id=222a312fdbb9220065dfd001cf96191e');
url.addParam('sysparm_query', g_list.getQuery({orderby: true, fixed: true}));
window.location = url.getURL();
}
This is working: I get the sys_id -> 222a312fdbb9220065dfd001cf96191e
<g:evaluate var="jvar_query" jelly="true" expression="RP.getParameterValue('sys_id')"/>
<h1>${jvar_query}</h1>
Does not work: jvar_query stays empty:
<g:evaluate var="jvar_query" jelly="true" expression="RP.getParameterValue('sysparm_query')"/>
<h1>${jvar_query}</h1>
Debug >>> JVAR: jvar_query=
I have created this client script to retrieve the sysparm_query value
function getSysparmQuery(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return decodeURIComponent(pair[1]);
}
}
}
How can I pass from the client script the variable to jelly?
This does not work:
<g:evaluate var="jvar_query" jelly="true" expression="getSysparmQuery('sysparm_query')"/>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 04:21 AM
Thank you for the information/update.
If you can get the sys_id, that suggests that the GlideURL line is working, and since you cannot get at the sysparm_query, that suggests that your url.addParam() is not working. I would look at constructing your URL another way. Have you tried it using a literal string?
e.g. window.location = 'ui_page.do?sys_id=sysparm_query=222a312fdbb9220065dfd001cf96191e&state%3D1';
From your UI context menu?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 12:37 PM
Thanks you for your suggestion but it does not work. I think I have the same problem with iFrame as mentioned in this disscussion: How to pass javascript variables into jelly tags?
I have build a workaround. I store the sysparm_query in the session and use it for further calculation. But now I have a strange effect that I must call the context menu twice so that the query is stored in the session. Do you have any ideas why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2016 01:02 PM
I solved the problem. I call the ui page direct from context menu like this:
runContextAction();
function runContextAction() {
var url = new GlideURL('my_uipage.do');
url.addParam('sysparm_query', g_list.getQuery({orderby: true, fixed: true}));
window.location = url.getURL();
}
Now I can get the sysparm values with ${RP.getParameterValue('sysparm_query')}. Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2016 11:23 AM
Please use:
<g:evaluate var="jvar_query" jelly="true" expression="RP.getParameterValue('sysparm_query')"/>