- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 05:45 AM
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 .
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 07:25 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 06:08 AM
Hi,
So if MRVS has 3 rows and each row has 4 columns so where it should be mapped?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 06:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 06:25 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2021 07:21 AM
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:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader