- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 03:45 AM
Hi All,
Anybody has an idea on how to pull values from url into a UI macro.
We have a UI macro which downloads all attachments attached to that particular catalog item.
from above url I want to fetch the sysparm_id value into a ui macro.
function popupDispAttachments() {
//var item_id = g_form.getParameter("sysparm_id");
//gs.addInfoMessage("sysparm id is": +item_id);
//Initialize the GlideDialogWindow
var attach_window = new GlideDialogWindow('display_attachment');
attach_window.setTitle('Download Attachment for New Catalog Item/Update Catalog Item');
attach_window.setPreference('table', 'sys_attachment_list');
attach_window.setPreference('sysparm_view', 'default');
//Set the table to display
//var num = g_form.getValue('number');
var item_id = getParmVal('sysparm_id');
var query1 = 'table_name=sc_cat_item';
attach_window.setPreference('sysparm_query', query1);
//Open the dialog window
attach_window.render();
function getParmVal(name) {
gs.log('Inside the UI Macro Download Attachment for Catalog Item');
var url = document.URL.parseQuery();
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 11:23 PM
Try below
var id = '${RP.getParameterValue('sysparm_id')}';
alert(id); // alert is giving the value of sysparm_id
attach_window.setPreference('sysparm_query', id);
And in the UI Page you can create the encoded query with sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 04:25 AM
Use below inside UI macro.
<g:evaluate var="jvar_uri">
var uri = RP.getParameterValue('sysparm_id');
</g:evaluate>
you can use the variable as ${jvar_uri}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 09:34 PM
Thanks for the response Ashish.
As you mentioned fetched the sysparm_id value into jvar_uri and could see that it is fetching correct sysid. However after fetching this value, I need to use it in function PopupDispAttachments, which is not happening now.
var query1 = 'table_name=sc_cat_item^table_sys_id=';
attach_window.setPreference('sysparm_query', query1);
Here for query1 table_sys_id, I need to assign the value fetched from URL(jvar_uri). I tried below ways but none seems to be working. How to use the value fetched from url into this query?
var query1 = 'table_name=sc_cat_item^table_sys_id='+${jvar_uri};
var query1 = 'table_name=sc_cat_item^table_sys_id='+uri;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 09:54 PM
if you are using the variable inside the <script> tag then try below
var dd = '$[jvar_uri]';
var query1 = 'table_name=sc_cat_item^table_sys_id='+dd;
Please Mark correct/Helpful if it helps you resolve the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 10:34 PM
I tried that, but no luck.
Is there anyway to pass jar_uri as an argument while calling the function?