Email Script for Multi Row Variable Set returning only the sys_id

Edxavier Robert
Mega Sage

Hi, 

I am creating an approval email notification where I need to display the values of a multi row variable set. I created an email script but is only returning the sys_id. So far this is what I have

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

          // Add your code here
	//Name of my multi row variable set is remove_group_members
	// Name of the variable is assignment_group
    var mrvs =" ";
    mrvs = current.sysapproval.variables.remove_group_members;
    var rowCount = mrvs.getRowCount();
    for (var i = 0; i < rowCount; i++) {
        var row = mrvs.getRow(i);
        template.print(row.assignment_group); 
    }
})(current, template, email, email_action, event);

 Here an example

EdxavierRobert_0-1670623908659.png

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Assuming the assignment_group variable within the MRVS is the type of reference, then that value will be stored as a sys_id which makes sense with what you are seeing.  I don't think you can dot-walk within the MRVS results so you need to do a GlideRecord on the sys_user_group table where the sys_id = row.assignment_group, then from the returned record use the Name field.  So something like this:

...
var row = mrvs.getRow(i);
var grp = new GlideRecord('sys_user_group');
grp.addQuery('sys_id', row.assignment_group);
grp.query();
if (grp.next()) {
    template.print(grp.name);
} 
...

 

View solution in original post

5 REPLIES 5

Hi Brad, 

I will try, but I am not sure how. 

 

Thanks for the suggestion.