- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 05:33 AM
Hello Geeks,
We have a requirement where in we need to export few specific fields to excel and attach on RITM. Please let us know if anyone has implemented this requirement?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 09:13 AM
Hello,
Test this
(function executeRule(current, previous /*null when async*/ ) {
generateData();
function generateData() {
var headers = ["Requested ITEM", "Opened By", "Request"];
var fileName = current.number + '.xls';
var xlsData = '';
// add headers to xlsData
for (var i = 0; i < headers.length; i++) {
xlsData += headers[i] + '\t';
}
xlsData += '\n';
// add data to xlsData
xlsData += current.number + '\t' + current.opened_by.getDisplayValue() + '\t' + current.request.getDisplayValue() + '\n';
// attach the file to a record.
var grRec = new GlideRecord("sc_req_item");
grRec.addQuery("sys_id", current.sys_id);
grRec.query();
if (grRec.next()) {
var grAttachment = new GlideSysAttachment();
grAttachment.write(grRec, fileName, 'application/vnd.ms-excel', xlsData);
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 06:35 AM - edited 02-09-2023 06:48 AM
Hi,
Can I see your code please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 07:50 AM
Please try this one
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 08:13 AM
Hello Ansar,
Still all the fields are coming on one column. They should come in separate columns.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2023 08:18 AM
Hi,
Please try this