- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2015 10:01 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2015 10:13 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2015 10:13 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2015 10:44 PM
Hi Travis,
Thanks a lot . It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 12:35 AM
Hi Travis,
I have another query, Please help me with it too.
I have 2 UI pages.In first UI page, i list all the records of a table along with a link and i am passing parameter through the link. When i click on the link,it takes me to second UI page, where i retrieve the parameter from url as u suggested before.Again am redirecting this parameter to a table, where the value of this parameter should get populated to a field in that table.
I have written the below code:
In first UI page:
<a href="action.do?sysparm_meetingId=$[meeting.u_meeting_id]">Link</a>
In second UI page:
<g2:evaluate var="jvar_act" object="true">
var meetingId = RP.getParameterValue('sysparm_meetingId');
</g2:evaluate>
<td><a href="meetings.do?sysparm_meeting_id=meetingId"><button>Add</button></a></td>
When i click on the "Add" button i want value of "meetingId" to get populated to "Meeting ID" field in Meetings table.
I have written client script for this.
function onLoad() {
//Type appropriate comment here, and begin script below
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
alert('You are in Meeting form');
var meetId = getParmVal('sysparm_meeting_id');
g_form.setValue('u_meeting_id',meetId);
}
Here when i click on "Add" button, form is loaded and i am getting alert message but value is not populating.
Can you let me know where i am wrong??
Thanks.
Jennifer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2015 02:27 AM
Hi. I did some modification and it worked!!
Thanks.
Jennifer