How to get values of Multi Row Variable Set into description field of a record porducer

Frans Brus - No
Tera Guru

We have a form in our Service Portal which customers can use to order something.
We use a Script to populate different fields from the record producer.

For example:

current.u_external_reference = producer.external_reference;
current.company = producer.account;
current.requested_by = producer.contact;
current.type = 'normal';
current.assignment_group = '5683776bdbab0300bb3288805b961926';
current.contact_type = 'self-service';

var description =
	"Box order for: "+ producer.contact + "\n" +
	"Quantity: " + producer.box_specifications.getRowCount();

Now we want to use a Multi Row Variable set which contain 2 fields.

  • Color
  • Dimensions

I already managed to get the Quantity value in above example.

But how do I get the values for each field in the Multi Row Variable set?
I want to see the box specifications as part of the description field.

Like:

var description =

                "Box order for: "+ producer.contact + "\n" +
                "Quantity: " + producer.box_specifications.getRowCount()
                "Color and Dimensions: " + ??? + "\n" +
                "Color and Dimensions: " + ??? + "\n" +
                "Color and Dimensions: " + ??? ;
                Etc…

It would be nice if for every row the customer ordered something, the specifications will be shown on a new row.

I already did some testing but that did not give any result.

	var description1 = '';
	var mrvs = producer.variables.box_specifications;

	var l = mrvs.getRowCount();
	for(var i = 0; i < l; i++) {
		var row = mrvs.getRow(i);
		var cells = row.getCells();

		var m = cells.length;
		for(var j = 0; j < m; j++) {
			description1+=cells[j].getLabel() + ': ' + cells[j].getCellDisplayValue() + "\n" ;
		}
current.comments='test ' + mrvs;

var description =
                "Box order for: "+ producer.contact + "\n" +
                "Quantity: " + producer.box_specifications.getRowCount()  + "\n" +
                "Color and Dimensions: " + "\n" + description1;

Hope anyone can help.

Many Thanks

1 ACCEPTED SOLUTION

Shruti
Mega Sage
Mega Sage

var mrvs = producer.variables.box_specifications;

var desc='';
 
for(var i=0; i<mvrs.length;i++){
   desc+="Color" + " : " +mvrs[i].color +" and "+"Dimension" + " : "+ mvrs[i].dimension + "\n" ;
}
 
 
Note: Replace color and dimension with the actual variable names in Multi row variable  set (mvrs[i].color and mvrs[i].dimension)

View solution in original post

5 REPLIES 5

Shruti
Mega Sage
Mega Sage

var mrvs = producer.variables.box_specifications;

var desc='';
 
for(var i=0; i<mvrs.length;i++){
   desc+="Color" + " : " +mvrs[i].color +" and "+"Dimension" + " : "+ mvrs[i].dimension + "\n" ;
}
 
 
Note: Replace color and dimension with the actual variable names in Multi row variable  set (mvrs[i].color and mvrs[i].dimension)

We are getting the sys ids, how can we get the display names/values. If we use .getDisplayValue() which returns undefined values, could you please help me on this?

I have the same case, were you able to solve it?

Hello Dinesh,

You probably already solved it, but I will leave it here in case some needs it in the future.

I had to do a glideRecord inside the for, in order to retrieve the display value.

var mrvs = JSON.parse(producer.VARIABLESETNAME);

var newMember;
var description = ''

for(var i=0; i<mrvs.length;i++){
	var grS = new GlideRecord("TABLENAME");
	if(grS.get(mrvs[i].new_member)){
		newMember = grS.getValue("name");
	}
   description += '\n' + 'Members: ' + newMember + " - "+ mrvs[i].ip_address + " - " + mrvs[i].port;
}
current.description = description;