Copy values from MRVS to RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2019 08:32 AM
Everyone,
I am trying to copy the selected "project" from a Lookup Select Box, within a Multi Row Variable Set, to a Multi Line Text variable called "time_tracker_projects" within the Request Item (RITM). Values within the Multi Row Variable Set are not visible within a report, so I need to copy them to the RITM so they can be visible on a report.
Multi Row Variable Set: time_tracker_hours
Below is a (BEFORE/INSERT) Business Rule I am trying to use, but the values are not getting written to the textbox.
Any ideas?
(function executeRule(current, previous /*null when async*/) {
// Get the Multi Row Variable Set - Time Tracker Hours
var mrvs = current.variables.time_tracker_hours;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
current.variables.time_tracker_projects += row.project;
}
})(current, previous);
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2019 09:29 AM
Check below useful video for MRVS scripting
https://www.youtube.com/watch?v=K4wvIzfv7eo
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2019 09:57 AM
Sachin,
Thanks, but that video doesn't help me. I need to capture values FROM the MRVS (Multi Row Variable Set) and copy them to a variable within the RITM. Once within a variable within the RITM, it could then be viewed inside a report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2019 10:13 AM
Hi Matt
Can you try to add MRVS variables int he way shown below and adjust as required and let me know if you run into any errors.
var mrvs = current.variables.time_tracker_hours;
var mrvsJSON = JSON.parse(mrvs);
for(var k=0; k<mrvsJSON.length; k++ ){
var tempJson= mrvsJSON[k];
current.variables.time_tracker_projects += tempJson['project'];
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2019 11:22 AM
Hey Ashok,
That is not working.
NOTE: I am using a "BEFORE" Business Rule. When I add gs.addInfoMessage both mrvs.getRowCount equals 0 and mrvsJSON.length equals 0.
Current Code:
(function executeRule(current, previous /*null when async*/) {
var mrvs = current.variables.time_tracker_hours;
var mrvsRowCount = mrvs.getRowCount();
gs.addInfoMessage(mrvsRowCount);
var mrvsJSON = JSON.parse(mrvs);
var mrvsJSONLength = mrvsJSON.length;
gs.addInfoMessage(mrvsJSONLength);
for(var k = 0; k < mrvsJSON.length; k++){
var tempJson = mrvsJSON[k];
current.variables.time_tracker_projects += tempJson['project'];
}
})(current, previous);
Any ideas???