Export multi-row variable set to excel or csv?

Brun
Mega Expert

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!

12 REPLIES 12

Prasad Dhumal
Mega Sage
Mega Sage

You can export from here :  

Navigate to sc_multi_row_question_answer.list

 

find_real_file.png

Filter your record appropriately and then Export.

John Zhang1
Kilo Patron
Kilo Patron

The following posts may help you:

Reporting on ServiceNow Variables

https://community.servicenow.com/community?id=community_question&sys_id=01fff6eddb58dbc01dcaf3231f96...

 

sc_item_option_mtom is the table name for variables and variable set

Brad Bowman
Kilo Patron
Kilo Patron

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);
}