How to map multi row variable set from record producer to case form

Renu9
Tera Contributor

How to create multi row variable set in the case form. It has to be with 3 columns and n number of rows on addition. 

Could anyone please suggest how it can be created in case UI .

1 ACCEPTED SOLUTION

@Renu 

You can use this script in before insert BR of Case Table

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

	// Add your code here

var mrvs = current.variables.mrvs; // your MRVS variable name here

var arr = [];

var parser = new global.JSON();
var parsedData = parser.decode(mrvs);

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

var obj = {};
obj['Date'] = parsedData[i].date.toString(); // give here the mrvs variable name of date
obj['Incident Details'] = parsedData[i].incident_details; // give here the mrvs variable name of incident_details
arr.push(obj);

}

current.setValue('u_name_value', JSON.stringify(obj)); // your Name-Value field name here

})(current, previous);

Regards
Ankur

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

View solution in original post

28 REPLIES 28

@Renu 

You can use this script in before insert BR of Case Table

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

	// Add your code here

var mrvs = current.variables.mrvs; // your MRVS variable name here

var arr = [];

var parser = new global.JSON();
var parsedData = parser.decode(mrvs);

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

var obj = {};
obj['Date'] = parsedData[i].date.toString(); // give here the mrvs variable name of date
obj['Incident Details'] = parsedData[i].incident_details; // give here the mrvs variable name of incident_details
arr.push(obj);

}

current.setValue('u_name_value', JSON.stringify(obj)); // your Name-Value field name here

})(current, previous);

Regards
Ankur

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

@Renu 

Thank you for marking my response as helpful.

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

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

Thanks Ankur, your response worked for us. Out of the value pairs, one is date field for us. Is it possible to mention the date type field ? Please find below screenshot. Date1, Dat2,... value should show date field types. 

find_real_file.png

Hi,

you can add logic to add counter

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

    // Add your code here

var mrvs = current.variables.mrvs; // your MRVS variable name here

var arr = [];

var parser = new global.JSON();
var parsedData = parser.decode(mrvs);

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

var obj = {};

var dateKey = 'Date' + parseInt(i+1);

var incidentKey = 'Incident Details' + parseInt(i+1);

obj[dateKey] = parsedData[i].date.toString(); // give here the mrvs variable name of date

obj[incidentKey] = parsedData[i].incident_details; // give here the mrvs variable name of incident_details

arr.push(obj);

}

current.setValue('u_name_value', JSON.stringify(obj)); // your Name-Value field name here

})(current, previous);

Regards
Ankur

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

can u give me the script for this?