Export multi-row variable set to excel or csv?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2021 02:28 PM
Hi Experts,
I'm began using some MRVS within an item, and find that it's really difficult to read from the task or RITM form due to the amount of columns and rows getting added. Has anyone been able to export a MRVS to an excel file or csv and attach it to the RITM?
If not, is there any way to make the table easier to read for the fulfiller? Even exporting to a PDF would be beneficial.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2021 02:36 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2021 02:45 PM
Filter your record appropriately and then Export.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2021 02:40 PM
The following posts may help you:
Reporting on ServiceNow Variables
sc_item_option_mtom is the table name for variables and variable set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2021 04:03 PM
Hi Brun,
I have created a UI Action to export a MRVS, and display it as a Form link, so the end users can see the link on the Catalog Task and open the table in Excel with one click. Here is the Script I am using which pushes each variable in each row of the MRVS into an array, then creates an attachment from the array, then redirects to the URL of the attachment which replicates the download action.
var mrvsexp = [];
var mrvs = current.variables.mrvs_internal_name;//replace with the internal name of your MRVS
var rowCount = mrvs.getRowCount();
mrvsexp.push('Model,Serial Number\r\n');//Column Headers - replace with your variable labels
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
//this next part is optional to convert a reference variable into the display value (name)
var mdl = new GlideRecord('cmdb_model');
mdl.addQuery('sys_id', row.v_mrvs2_model);
mdl.query();
if(mdl.next()){
//and in this case I only wanted to export MRVS rows with the serial_number variable blank
if(row.v_mrvs2_serial_number == '' || row.v_mrvs2_serial_number == null || row.v_mrvs2_serial_number == undefined){
mrvsexp.push(mdl.display_name + ',' + row.v_asset_tag + '\r\n');
}
}
}
var attachment = new Attachment();
var attachmentRec = attachment.write('sc_task', current.sys_id, 'network gear assets.csv', 'text/csv', mrvsexp.join(''));
var att = new GlideRecord('sys_attachment');
att.addQuery('file_name', 'network gear assets.csv');
att.addQuery('table_sys_id', current.sys_id);
att.orderByDesc('sys_created_on');
att.query();
if(att.next()){
var snEnv = gs.getProperty('instance_name');
var attsysid = att.sys_id.toString();
var URL = "https://" + snEnv + ".service-now.com/sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=" + attsysid;
current.update();
action.setRedirectURL(URL);
}
else{
current.update();
action.setRedirectURL(current);
}