RP.getParameterValue('sysparm_rec_id') is not working

Dazler
Mega Sage

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.

1 ACCEPTED SOLUTION

Rajesh Kannan G
ServiceNow Employee
ServiceNow Employee

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.

find_real_file.png

Regards,

Rajesh

View solution in original post

15 REPLIES 15

You need to pass the parameter "sysparm_criteria" value should be an encoded query build using condition builder in sys_user list. For example you can pass sysparm_criteria=sys_id=60beb5e7d7600200e5982cf65e6103ad

Regards,

Rajesh

I did do that and it didn't work.  I know my URL parameter is working because to test that the parameter is being passed to that new URL, I put the following code in the Client script of the UI page and I added an alert to see that parameter being passed.

window.onload = function(){

    alert('I am an on-load alert! ' + sysparm_rec_id);

};

//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 getParameterValue(name){
    var url = document.URL.parseQuery();
    if(url[name]){
        return decodeURI(url[name]);
    }
    else{
        return;
    }
	}

 

find_real_file.png

As you can see in the above image, the parameter is being passed, now my question is if it is able to be passed to the client script then why isn't it being passed to the Jelly?

And if I have that variable in the client script, how can I pass the variable to the jelly from the client script?

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

Only one change:

<j:set var="jvar_sysID" value="${RP.getParameterValue('sysparm_rec_id')}"/>

 

Add jelly="true" in this above line as below

 

<j:set var="jvar_sysID" value="${RP.getParameterValue('sysparm_rec_id')}" jelly="true"/>


Thanks,
Ashutosh

This didn't work either. It's just blank. 

Hi,

Why are you not using GlideDialog window to open this UI page?

Thanks,

Ashutosh