How to fetch parameters passed through url from one UI page to another UI page and use that parameter to query in second UI page?

jenny32
Tera Guru


HI All,

I am facing problem in accessing the parameters passed through url.In my first UI page i am passing a "meetingId" value through url and fetching that parameter in my second UI page and use this value to query in second UI page.

I used the below code:

In my first page:

<a href="add.do?sysparm_meetingId=$[meeting.u_meeting_id]">Link</a>

In second UI page:

<j:set var="jvar_meeting_id" value="${sysparm_id}" />

<g2:evaluate var="jvar_act" object="true" jelly="true">

      var act = new GlideRecord('u_actionitem');

      act.addQuery('u_meeting_id','=', jelly.jvar_meeting_id);

      act.query();        

</g2:evaluate>

Code doesn't work.

Any help will be highly appreciated.

Thanks.

Jennifer

1 ACCEPTED SOLUTION

tltoulson
Kilo Sage

Hi Jennifer,



I think you've nearly got it.   One thing stands out to me, on your second UI Page, that first line should change to:



<j:set var="var_meeting_id" value="${sysparm_meetingId}" />



Notice that the value inside the dollar sign - curly braces is the same as the parameter value passed in the first UI Page.   This is a convention used by ServiceNow and is documented here: http://wiki.servicenow.com/index.php?title=UI_Pages#Invoking_a_Page



Personally, I prefer to to declare this more explicitly using RP.   Personally, I find the parameter convention makes the script harder to understand.   Here is the more explicit approach that I like for the second page:



<g2:evaluate var="jvar_act" object="true">


      var meetingId = RP.getParameterValue('sysparm_meetingId');


      var act = new GlideRecord('u_actionitem');


      act.addQuery('u_meeting_id','=', meetingId);


      act.query();    


</g2:evaluate>



I hope this has helped!



Edit:   Heres the docs on RP Extensions to Jelly Syntax - ServiceNow Wiki


View solution in original post

7 REPLIES 7

Hi Jennifer


Can you please tell what changes you made to make the code work


Hi Surya,



I initially made that field as read-only in the form and tried to auto-populate the values from UI page but it didn't work, so I disabled 'Read-only' option for that field and tried and I was able to auto-populate the value to that field when I click on the 'Add' button.


johnram
ServiceNow Employee
ServiceNow Employee

The ServiceNow Wiki content is no longer supported. Updated information about this topic is located here: UI Pages
 


Visit http://docs.servicenow.com for the latest product documentation