- 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 10:41 PM
Could you please paste the code of your UI macro, then i can have a look on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2015 10:58 PM
Sure Ashish.. Here is the code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<g:evaluate object="true" var="jvar_uri" jelly="true" >
var uri = RP.getParameterValue('sysparm_id');
gs.log("inside macro " + uri);
</g:evaluate>
<button onclick="popupDispAttachments();"> Click Here to download the Attachment for New Catalog Item/Update Catalog Item</button>
<script>
function popupDispAttachments() {
//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 = RP.getParameterValue('sysparm_id');
var query1 = 'table_name=sc_cat_item^table_sys_id=' ;
attach_window.setPreference('sysparm_query', query1);
//Open the dialog window
attach_window.render();
}
</script>
</html>
</j:jelly>
- 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-24-2015 12:32 AM
Thank you so much Ashish.
Its working perfectly fine