- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2014 08:06 AM
Hi,
While calling a UI Page through UI Action how can I pass a parameter to below line in UI Page.I have a UI page to display po header with line items and I would like to know how can I pass the current PO number to retrieve the data for that particular po.
gr.addQuery ('number','=','parameter_from_url');
Any help in this regard will be highly appreciated.
Thanks,
Sami.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2014 03:06 AM
Here we go...
assume the following is your url:
https://instance.service-now.com/ui_page.do?sysparm_id=6e1e02ac4d3c5d00407eccb253aa2b13
Retrieve Parameter Value from within a UI page:
<g:evaluate var="sysparm_id">
var sysparm_id = RP.getParameterValue("sysparm_id"); -> here you specify the name of your parameter !
sysparm_id;
</g:evaluate>
Use parameter in your script:
<g:evaluate var="jvar_user" object="true" jelly="true">
var gr = new GlideRecord("sys_user");
gr.get(jelly.sysparm_id);
gr;
</g:evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2014 11:41 AM
Assuming that the parameter is in the url, you can parse the url for what you need.
You can use document.referrer to get the referring url or use window.location to use the current url.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2014 11:42 PM
Thanks Justin for the response,I would like to know how can we do this using Jelly or if I am using java script how can we utilize the returned parameter value in Jelly.For Example
Below function returns the value of parameter po number.
function getParam( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
return results[1];
}
var pono= getParam( 'po' );
// alert (pono);
I would like to know how can we use the above returned value in the 3rd line of below code
1.<g:evaluate var="jvar_groups" object="true">
2. var gr = new GlideRecord("u_purchase_order_report");
3. gr.addQuery ('poh_number','=','pono');
4. gr.query();
5. gr;
6.</g:evaluate>
I used below code to save the value of po from url https://myinstance.service-now.com/po_report.do?po=PO0000009) but it is not capturing the parameter value in ${jvar_po_no}.Can any one please correct me if anything is missing here?
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_po_no" value="${po}" />
<g:evaluate var="jvar_groups" object="true">
var gr = new GlideRecord("u_purchase_order_report");
//gr.groupBy('purchase_order');
gr.addQuery ('poh_number','=','${jvar_po_no}');
gr.query();
gr;
</g:evaluate>
Sami.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2014 07:44 AM
Sami,
Just one note:
Here a simple example to retrieve params from URL Prototype v1.7.2 API documentation | String#toQueryParams
[]'s
Andre Moreira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2014 03:06 AM
Here we go...
assume the following is your url:
https://instance.service-now.com/ui_page.do?sysparm_id=6e1e02ac4d3c5d00407eccb253aa2b13
Retrieve Parameter Value from within a UI page:
<g:evaluate var="sysparm_id">
var sysparm_id = RP.getParameterValue("sysparm_id"); -> here you specify the name of your parameter !
sysparm_id;
</g:evaluate>
Use parameter in your script:
<g:evaluate var="jvar_user" object="true" jelly="true">
var gr = new GlideRecord("sys_user");
gr.get(jelly.sysparm_id);
gr;
</g:evaluate>