The CreatorCon Call for Content is officially open! Get started here.

Adding values from a multi row variable set to an email notification

Bidduam
Tera Guru

I am trying to add the values from a multi row variable set and I'm just not having any luck.

 

I've had a look at these:

The one I've tried is:

How to Display Multi Row Variable set (MRVS) data... - ServiceNow Community

 

My MRVS is as follows:

Internal Name: other_items

Type: Multi Row

Layout: 1 Column Wide

I only have one variable within the MRVS

Name: other_options 

Type: Single Line Text

 

My current mail script is:

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


    // This sets the font size and type

    var mrvs = current.variables.other_items; // MRVS Internal name
    var rowCount = mrvs.getRowCount();
    if (rowCount >= 1) {
        template.print("<table border =1>");
        template.print("<tr>");
        template.print("<th>Others</th>");
        template.print("</tr>");
        for (var i = 0; i < rowCount; i++) {
            template.print("<tr>");
            var row = mrvs.getRow(i);
            template.print("<td>" + getName(row.others.toString(),'current.variables.other_options') + "</td>");
            template.print("</tr>");
        }
        template.print("</table>");
    }

    //This function accept sys_id and table and returns the Display name.
    function getName(sys_id, tblName) {
        var rec = new GlideRecord(tblName);
        if (rec.get(sys_id)) {
            return rec.getDisplayValue();
        }
    }
	
})(current, template, email, email_action, event);

 

All it is returning is the table border and heading, no variable values

 

What am I missing.

10 REPLIES 10

@Ed Hefford 

Thank you for sharing your code, I have had a look at it now on a couple of occasions and I just don't see how I edit it to get the values from my MRVS?

If you are able to assist with that I'd be very appreciative.