Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display variable and Multiple row variable sets data into approver email.

Insider
Giga Guru

Hello,

I am trying to display variable and multiple row variable set data in an approval email notification.

in a line by line manager. as shown in the picture.

 

Process: A case gets created with variables and multiple row variable sets, then approver gets triggered and then this email gets triggered to approver.
i am currently using this script in email script to print the variable data but now i need for both variables and multiple row variable sets.

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
 
    template.print('<table border="1">');
    var item = new GlideRecord('x_gskgs_gsf_case_1_finance_procurement_case');
    item.get('sys_id', current.sysapproval);
    for (var key in item.variables) {
        template.print("<tr>");
        if (item.variables[key]) {
            gs.info("Hello  " + getQuestionLabel(key));
 
            if (getQuestionLabel(key) != 'Routing Type' && getQuestionLabel(key) != 'undefined' && getQuestionLabel(key) != ' ' && item.variables[key].getDisplayValue() != ' ' && item.variables[key].getDisplayValue() != 'false' && getQuestionLabel(key) != 'false') {
                template.print("<td>" + getQuestionLabel(key) + "</td>\r\n");
                template.print("<td>" + item.variables[key].getDisplayValue() + "</td>\r\n");
                template.print("</tr>");
            }
        }
 
    }
    template.print("</table>");
 
    function getQuestionLabel(question) {
        var vara = new GlideRecord('item_option_new');
        vara.addQuery('name', question);
        vara.query();
        if (vara.next()) {
gs.info('variable '+vara.question_text+"  "+question);
            var question_label = vara.question_text;
            return question_label;
 
        }
    }
})(current, template, email, email_action, event);
 
Please help!
6 REPLIES 6

Re: the AI link - It gives you steps, but does not  necessarily solve the issue.   

Insider
Giga Guru

@Ankur Bawiskar 
hello Ankur, this is insider from the other post.
can You help me with this please

@Insider 

check this link and it has solution

How to Display Multi Row Variable set (MRVS) data in a notification 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks a lot Ankur.
Will this also print the other variable data from the form?

I am trying to print both variable data and MRVS data on notifications.