- 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
06-04-2021 12:38 PM
OK, we'll get there. This example assumes u_name is the name of a MRVS variable of the reference type. First try this if you haven't already.
var name = {};
var arr = [];
var mrvs = producer.termination;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
name[row.u_name.getDisplayValue()] = row.date_need_access_terminated;
arr.push(name);
current.employees_affected = JSON.stringify(name);
}
If that doesn't do anything, causes an error, or still shows the sys_id, we can add a GlideRecord query. Assuming the reference table on this variable is x_344184_finance_a_treasury, and there's a field named emp_name on that table which holds the value to be displayed instead of the sys_id, your script would look like this.
var name = {};
var arr = [];
var mrvs = producer.termination;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var gr = new GlideRecord('x_344184_finance_a_treasury');
if(gr.get(row.u_name)){
name[gr.emp_name] = row.date_need_access_terminated;
arr.push(name);
current.employees_affected = JSON.stringify(name);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2021 01:38 PM
I think the last line may be causing the issue.
employees_affected = name of the Name-Value Pair field on form
var name = {};
var arr = [];
var mrvs = producer.termination;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
var gr = new GlideRecord('x_344184_finance_a_treasury');
if(gr.get(row.u_name)){
name[gr.emp_name] = row.date_need_access_terminated;
arr.push(name);
current.employees_affected = JSON.stringify(name);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2021 12:30 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2021 09:24 AM
Having this same issue:
I have a MRVS on a record producer that I want the values added to map to the description field on the resulting HR case record. Below is an example of my MRVS with the fields that values are entered for.
The 2 variables in my MRVS are 'state' and 'allocation_percentage'
I tried using this UI Policy OnCondition script on the record producer but it did not work
function onCondition() {
var varName = JSON.parse(producer.state_withholding_elections);
var description = '';
for (var i = 0; i < varName.length; i++) {
description += "\n state: " + varName[i].state + "\n allocation_percentage: " + varName[i].allocation_percentage + "\n";
}
current.case_field = description;
}