Passing two parameters in an URL

abcxyz
Kilo Explorer

Hello,

I need to pass two dynamic parameters in an URL and need to retrieve the parameters in the next page.

I have written a script in the dynamic content block and passing the parameters as below.

<a href="https://sssdev.service-now.com/sdsds/Sub_category_page.do?sysparm_my_sysid=${gr.sys_id}${AMP}sysparm_my_sysid1=${gr.catalogsys_id}"> View All</a>.

I need to retrieve the parameters sysparm_my_sysid and sysparm_my_sysid1.

I can retrieve the first parameter using RP.getParameterValue() as below.

<g:evaluate var="jvar_rel1" jelly="true" object="true">

  var rel1 = new GlideRecord('sc_category');

  rel1.addQuery('active',true);

  rel1.addQuery('sys_id', jelly.RP.getParameterValue('sysparm_my_sysid'));

  rel1.query();

  rel1;

</g:evaluate>

But Cannot retrieve the second parameter.

I was suggested to use RP.getParameters();

Can someone guide me how can I use RP.getParameters(); or any other method to achieve this.

Thank you in advance,

8 REPLIES 8

Brad Tilton
ServiceNow Employee
ServiceNow Employee

You should be able to use getParameterValue() with both, but I would remove the number from the second parameter and see if that helps.


abcxyz
Kilo Explorer

Hey Brad,



I just removed the number and tried like this



<a href="https://sssdev.service-now.com/sdsds/Sub_category_page.do?sysparm_my_sysid=${gr.sys_id}${AMP}sysparm_catalog_sysid=${gr.catalogsys_id}"> View All</a>



and used RP.getParameterValue twice to retrieve parameters. But still no luck:-(



<g:evaluate var="jvar_rel1" jelly="true" object="true">

  var rel1 = new GlideRecord('sc_category');


  rel1.addQuery('active',true);


  rel1.addQuery('sys_id', jelly.RP.getParameterValue('sysparm_my_sysid'));


  rel1.query();


  rel1;


</g:evaluate>



<g:evaluate var="jvar_rel" jelly="true" object="true">

  var rel = new GlideRecord('sc_catalog');


  rel.addQuery('active',true);


  rel.addQuery('sys_id', jelly.RP.getParameterValue('sysparm_catalog_sysid'));


  rel.query();


  rel;


</g:evaluate>


Manjul Katare
ServiceNow Employee
ServiceNow Employee

Try this out:



Assume your two variables are in the URL: "&req_type=ONE&type_group=TWO"



Then you can use this in your java script as:



var url = window.location.toString();


var parms = url.toQueryParams();


parms["req_type"]   // You can pass its value to jelly variable


parms["type_group"]   // You can pass its value to jelly variable



Hope this help!


-Manjul


Hey Manjul,



Thanks, I would try this.



Do I have to save parms["req_type"] and parms["type_group"] in any variables?



And in the code   I will be replacing   jelly.RP.getParameterValue('sysparm_my_sysid') with jelly.parms["req_type"] right?