how to map the variables values from a MULTI ROW VARIABLE SET variables to a custom table .

surya76
Tera Contributor

Created a multi row variable set in portal:

image

these are getting to a RITM in my requested items . from there how to map MULTI ROW VARIABLE SET variables to a custom table

how to map the variables values from a MULTI ROW VARIABLE SET variables to a custom table .

i am able to map the variables values from a single row variable set to a custom table using a business rule to run run on set_req_item table :

var cret = new GlideRecord('u_police_fir');
cret.initialize();
 cret.fir_type = current.variables.case_no;
cret.insert();

 

HOW TO DO THE SAME FOR MULTI ROW VARIABLE SET:

when i click on request in service portal

Row 1=>date and location to be mapped in a ticket =>1001

Row 2=>date and location to be mapped in a ticket =>1002

Row 3=>date and location to be mapped in a ticket =>1003

For every row an individual ticket should be created

In ticket 1001 contains u_date field and u_location field

There Row 1=>date and location to be mapped in a ticket

In ticket 1002 contains u_date field and u_location field

Row 2=>date and location to be mapped in a ticket =>1002

In ticket 1003 contains u_date field and u_location field

There Row 3=>date and location to be mapped in a ticket

 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use after insert BR on sc_req_item table

Condition: current.cat_item.name == 'Your Item Name Here'

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here

	var variableValue = current.variables.<MRVSvariableName>;

	var parser = JSON.parse(variableValue);

	var gr = new GlideRecord('table_name');

	for(var i=0;i<parser.length;i++){

		gr.initialize();

		gr.field1 = parser[i].ticket_number;

		gr.field2 = parser[i].ticket_description;

		gr.field3 = parser[i].ticket_working_time;

		gr.field4 = parser[i].ticket_number;

		gr.insert();

	}

})(current, previous);

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

can you send me documentation regarding this

 

Hi,

check this

Multi Row Variable set ServiceNow MRVS - Creating - Scripting - Example - Limits

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Link is not working