Copy values from MRVS to RITM

Matt Cordero1
Tera Guru

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);
8 REPLIES 8

sachin_namjoshi
Kilo Patron
Kilo Patron

Check below useful video for  MRVS  scripting

 

https://www.youtube.com/watch?v=K4wvIzfv7eo

 

Regards,

Sachin

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.

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

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);

find_real_file.png

find_real_file.png

Any ideas???