Copying ServiceNow Outputs to an Excel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 04:02 AM
Java script code to export data (Outputs) from ServiceNow instance and copy it to an excel sheet.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 04:27 AM
@Priyobroto Roy1 Please refer to this thread https://www.servicenow.com/community/developer-articles/generate-csv-file-through-script/ta-p/231977... to know the steps to generate a CSV file via script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2024 04:27 AM
Please use the following script as per your need
var attachment = new GlideSysAttachment(); /
/set up inputs var rec = new GlideRecord('incident');
rec.get('78271e1347c12200e0ef563dbb9a7109');
var fileName = 'example.txt'; var contentType = 'text/csv';
var content = 'The text that is stored inside my file'; var agr = attachment.write(rec, fileName, contentType, content); gs.info('The attachment sys_id is: ' + agr);
ServiceNow URL for Reference https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server/no-namespace/c_GlideSysAttachm...
Please let me know if the answer is helpful