- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 02:42 AM
Hi All,
Please guide on, how i can export data into excel [.xlsx] via script.
Regards,
Suresh.
Solved! Go to Solution.
- Labels:
-
Incident Management
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2021 08:06 AM
we forgot adding the underscore
now it should work fine
g_navigation.open('/' + tableName + '_list.do?EXCEL&sysparm_view=ess', '_blank');
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
05-10-2021 11:32 PM
Hi,
you might have to develop some UI page and ask user to set some filter and then download the record
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
05-11-2021 02:17 AM
Hi All,
Any one can give suggestions for script.
Regards,
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 02:44 AM
Please check below links for UI page help
https://servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/
https://www.learnnowlab.com/UI-Page-example/
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 04:27 AM
Hi ,
Please suggest on this. Not working the below code in UI Action .
var output = "Number,Company,Short_Description,Incident State"; //header for csv file
var table = "incident";
var recordId = ""; //using for attachment file
var gr = new GlideRecord(table);
var query = current.getParmVal('sysparm_query');
gr.addEncodedQuery(query);
gr.query();
var count = 0;
while (gr.next()) {
count++;
output += "\n" + gr.number + "," + gr.company.getDisplayValue() + "," + gr.short_description + "," + gr.incident_state.getDisplayValue();
if (!recordId) {
recordId = gr.sys_id;
}
}
gs.print(recordId);
writeAttachmentFile(output);
function writeAttachmentFile(data) {
var attachment = new Attachment();
var attachmentRec = attachment.write(table, recordId, "export.csv", "text/csv", data);
}
Regards,
Suresh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2021 05:25 AM
Hi,
update as this
var output = "Number,Company,Short_Description,Incident State"; //header for csv file
var table = "incident";
var recordId = ""; //using for attachment file
var gr = new GlideRecord(table);
var query = gs.action.getGlideURI().getMap().get('sysparm_query');
gr.addEncodedQuery(query);
gr.query();
while (gr.next()) {
output += "\n" + gr.number + "," + gr.company.getDisplayValue() + "," + gr.short_description + "," + gr.incident_state.getDisplayValue();
}
gs.info(recordId);
writeAttachmentFile(output,current);
function writeAttachmentFile(data,currentObject) {
var attachment = new Attachment();
var attachmentRec = attachment.write(currentObject, "export.csv", "text/csv", data);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader