- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2018 09:17 PM
i need to get the value from "g:ui_reference" for the sys_script(which displays all the tables).when i select the table and click on download it should download all the records in Xlsx format.Suppose if we have an incident table selected ..the incident table which consists of active records must be downloaded in Xlsx format.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 12:07 AM
Hi Subhanand,
Following script you can use in UI page
HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_instanceName" object="true">
var instanceName = gs.getProperty('instance_name');
instanceName;
</g:evaluate>
<g:ui_reference name="tables" id="tables" table="sys_db_object" completer="AJAXTableCompleter"/>
<input type="hidden" id="hidden" value="${jvar_instanceName}"/>
<input type="button" value="Download Excel" onclick="download()"></input>
</j:jelly>
Client Script:
function download(){
var instanceName = gel('hidden').value;
var table = gel('tables').value;
var tableGr = new GlideRecord('sys_db_object');
tableGr.addQuery('sys_id', table);
tableGr.query();
if(tableGr.next()){
var url = 'https://' + instanceName + '.service-now.com/' + tableGr.name + '_list.do?XLS';
window.open(url);
}
}
Care to be taken since it doesn't specify any query so it will try downloading all records. you can specify the view as well so as to include only necessary columns using sysparm_view parameter in URL
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2018 12:33 AM
Hi Subhanand,
you can use condition builder type of field in UI page and get the condition and use accordingly. but it won't be straight forward.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader