- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 07:38 AM
1. create a download button that should appear on the incident form to download the record in CSV format
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 10:01 AM
This should help you
UI Action:
function downloadFile(){
var sysId = g_form.getUniqueValue();
var tableName = g_form.getTableName();
var gDialog = new GlideDialogWindow('download_csv');
gDialog.setSize('600','600');
gDialog.setPreference('sysparm_sysID', sysId);
gDialog.setPreference('sysparm_tableName', tableName);
gDialog.setTitle('Download Incident');
gDialog.render();
}
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:ui_form>
<input type="hidden" name="recordSysId" id="recordSysId" value="${sysparm_sysID}"/>
<input type="hidden" name="tableName" id="tableName" value="${sysparm_tableName}"/><input type="button" onclick="downloadCSV()" name="Download" value="Download"></input>
<input type="button" onclick="onCancel()" name="Cancel" value="Cancel"></input>
</g:ui_form>
</j:jelly>
Client Script:
function downloadCSV(){
var tableName = gel('tableName').value;
var recordSysId = gel('recordSysId').value;
top.window.open('/' + tableName + '.do?CSV&sys_id='+recordSysId); // Is working fine
GlideDialogWindow.get().destroy();
}
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
Output:
Once they click "Download" the record would be downloaded as CSV
If they click "Cancel" the dialog window will be closed
Regards
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
‎09-07-2020 06:40 AM
Hi Ankur,
I created a ui page for the same, in Ui page when I tried it is working fine.
But when I tried from UI action nothing is happening
Can you please explain this more like your ui page name given and ui action details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 07:30 AM
Hi Parnika,
I would encourage to create a new question for this as it would be easier to keep track of.
please post the question link here and I can take a look on that
Regards
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
‎09-07-2020 07:49 AM
Hi Parnika,
Please create a UI page with the name download_csv
download_csv