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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So if MRVS has 3 rows and each row has 4 columns so where it should be mapped?

Regards
Ankur

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

Hi Ankur, it has to be mapped in the case form to a table field.

In record producer, im having as below.

find_real_file.png

In the same way, this has to be copied into the case form UI when we hit the submit button from record producer.

Hi,

yes but date and incident/Details should be mapped to which fields in target table?

please share which target fields image to be set and also as there are 2 rows what about the other row?

Regards
Ankur

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

@Renu 

you can use this to populate name-value pair

Sample below

var arr = '[{"variable":"jm_template_variable","type":"xlrelease.StringVariable"},{"variable":"jm_template_var2","type":"xlrelease.StringVariable"},{"variable":"jm_date","type":"xlrelease.DateVariable"},{"variable":"jm_boolean","type":"xlrelease.BooleanVariable"},{"variable":"jm_array","type":"xlrelease.ListStringVariable"},{"variable":"jm_integer","type":"xlrelease.IntegerVariable"}]';

var parser = JSON.parse(arr);

var obj = {};

for(var i=0;i<parser.length;i++){
obj[parser[i].variable] = parser[i].type;
}

g_form.setValue('u_name_value', JSON.stringify(obj));

Output:

find_real_file.png

Regards
Ankur

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