Mapping the MRVS field value to the custom table field

Janu sree
Tera Guru

Hello Community,

 

We have a requirement to map the field of Multi Row Variable set values to the custom table fields.

 

I am using the below code in record producer to map the multi-row variable set field 'Name and Number' to the field of a table extended from case.

Code is working but i am getting the field name as well along with value. and also how to get the Only values mapped to the table field in row wise like if multiple entries are there

PS: I'm using string field type in custom table.

 

var FR = producer.please_list_all_escorts_or_persons;
var arr = [];
var parsedData = JSON.parse(FR);
for (var i = 0; i < parsedData.length; i++) {
    var obj = {};
    obj['Name and Number'] = parsedData[i].name_var_set;
    arr.push(obj);
}
current.setValue('nam0'JSON.stringify(arr)); 

 

 

RatnaJyothi_0-1686138772417.png

 

2 ACCEPTED SOLUTIONS

jaheerhattiwale
Mega Sage
Mega Sage

@Janu sree Tried and tested solution. Please use below code

 

var FR = producer.please_list_all_escorts_or_persons;
var arr = [];
var parsedData = JSON.parse(FR);
for (var i = 0; i < parsedData.length; i++) {
    var bulletNumber = i+1;
    arr.push(bulletNumber+". "+parsedData[i].name_var_set);
}

arr = arr.toString();
arr = arr.replaceAll(",","\n");
current.setValue('nam0', arr);
 
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

This should work
 
var FR = producer.please_list_all_escorts_or_persons;
var arr = [];
var parsedData = JSON.parse(FR);
for (var i = 0; i < parsedData.length; i++) {
    var count = i+1;
    arr.push(count  + ". " + parsedData[i].name_var_set + "");
}
current.setValue('nam0', arr.join("\n")); 
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

8 REPLIES 8

This should work
 
var FR = producer.please_list_all_escorts_or_persons;
var arr = [];
var parsedData = JSON.parse(FR);
for (var i = 0; i < parsedData.length; i++) {
    var count = i+1;
    arr.push(count  + ". " + parsedData[i].name_var_set + "");
}
current.setValue('nam0', arr.join("\n")); 
If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

jaheerhattiwale
Mega Sage
Mega Sage

@Janu sree Tried and tested solution. Please use below code

 

var FR = producer.please_list_all_escorts_or_persons;
var arr = [];
var parsedData = JSON.parse(FR);
for (var i = 0; i < parsedData.length; i++) {
    var bulletNumber = i+1;
    arr.push(bulletNumber+". "+parsedData[i].name_var_set);
}

arr = arr.toString();
arr = arr.replaceAll(",","\n");
current.setValue('nam0', arr);
 
Please mark as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@Janu sree Did you try this?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Its working.. Thanks