- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 11:27 AM
Hi,
I am trying to pass variable in a URL from a UI Action to a UI Page. The variable is passing to the URL, but when I try to pull it into the UI Page, it is blank.
What am I doing wrong?
We need this because the UI Page opens up in a new window and displays all the attachments of a catalog task ticket. This will allow a print function.
But I need the sys_id of that catalog task to pass to the UI page, when the button is clicked on the catalog task.
This is my code in the HTML of the UI Page.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- GLIDERECORD in JELLY -->
<g2:evaluate var="jvar_attachments" object="true" jelly="true">
<j:set var="jvar_sysID" value="${RP.getParameterValue('sysparm_rec_id')}"/>
var sysID = jelly.jvar_sysID;
var label = [];
var sysAttachmentGR = new GlideRecord('sys_attachment');
sysAttachmentGR.addQuery('table_sys_id', sysID);
sysAttachmentGR.addQuery('table_name', 'sc_task');
sysAttachmentGR.query();
while(sysAttachmentGR.next()){
label.push(sysAttachmentGR.sys_id.toString());
}
label;
</g2:evaluate>
I have tried so many ways, but it keeps returning blank.
This is the code for the UI Action that passes the variable.
function openPrint() {
var scTask = g_form.getUniqueValue();
var href = "ui_page.do?sys_id=b4b2b5f7db2d1c50346fe&sysparm_rec_id=" + scTask;
window.open(href, "UPS - Print Label(s)");
}
Please, I really need help to get this completed.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2020 01:42 AM
Have attached XML records for a UI Action and a UI Page. The UI Action "Print Labels" on sc_task opens the UI Page to show the images attached to current sc_task record. Follow this procedure to Import the XML records.
Regards,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:33 PM
Because I cannot print from the GlideWindow. I need to print these labels and when I tried to use the GlideWindow it did not work. The problem that I am having is that after I set the print area of the glidewindow it would only print the 1st page and not what is within the print area.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:35 PM
I am trying to set it so that the UI page opens in a new window. This gives me control of the print function of a page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 01:34 PM
Can I use the below script in the Client Script of the UI Page to pull the URL parameter and then pass it to the jvar_sysID?
Here is a the script:
function onLoad() {
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var sysparm_rec_id = getParmVal('sysparm_rec_id');
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 05:21 PM
Can someone please help me with this? This is an important piece to my project in ServiceNow. The RP.getParameterValue is not working for me. As I mentioned before the parameter that I included "sysparm_rec_id" is in the URL and I used a client script parameter retrieval on the UI Page to see if the client script it passing the parameter and it is.
But it is not passing it to the Jelly on the UI Page. The value is key to running my query to retrieve data back from the server.
Please, am I missing something? Does something need to be activated? I need this due to the Print restrictions on the GlideWindow. It is only printing the first page even after setting print area.
I have tried several ways:
1. <j:set var="jvar_sysID" value="RP.getParameterValue('sysparm_rec_id')" />
2. <j:set var="jvar_sysID" value="$[RP.getParameterValue('sysparm_rec_id')]" />
3. <j:set var="jvar_sysID" value="${RP.getParameterValue('sysparm_rec_id')}" />
4.<g2:evaluate var="jvar_sysID" expression="${RP.getParameterValue('sysparm_rec_id')}"/>
5. <g2:evaluate var="jvar_sysID" expression="$[RP.getParameterValue('sysparm_rec_id')]"/>
I have tried so many ways.
I have a client script that can parse the URL and it works. I know that client script cannot pass values to Jelly because Jelly is on server side but is there any way that I can get that value from the client to the HTML?
This is my current HTML script:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- <g2:evaluate var="jvar_sysID" expression="$[RP.getParameterValue('sysparm_rec_id')]" jelly="true"/> -->
<!-- GLIDERECORD in JELLY -->
<g2:evaluate var="jvar_attachments" object="true" jelly="true">
var label = [];
var sysAttachmentGR = new GlideRecord('sys_attachment');
sysAttachmentGR.addQuery('table_sys_id', 'jelly.jvar_sysID');
sysAttachmentGR.addQuery('table_name', 'sc_task');
sysAttachmentGR.query();
while(sysAttachmentGR.next()){
label.push(sysAttachmentGR.sys_id.toString());
}
label;
</g2:evaluate>
<g:ui_form>
<p>Test: ${jvar_sysID}</p>
<j2:forEach items="$[label]" var="jvar_images">
<img class="user_image" src="$[jvar_images].iix" style="max-width:100% !important; max-height:100% !important; padding-bottom:50% !important;"/>
</j2:forEach>
</g:ui_form>
</j:jelly>
This is the client script of the UI action that is parsing the URL.
var sysparm_rec_id = getParmVal('sysparm_rec_id');
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
If I called a glide AJAX in the client script how can I get that value in my foreach loop.
<j2:forEach items="$[label]" var="jvar_images">
<img class="user_image" src="$[jvar_images].iix" style="max-width:100% !important; max-height:100% !important; padding-bottom:50% !important;"/>
</j2:forEach>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2020 01:42 AM
Have attached XML records for a UI Action and a UI Page. The UI Action "Print Labels" on sc_task opens the UI Page to show the images attached to current sc_task record. Follow this procedure to Import the XML records.
Regards,
Rajesh