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.

How to populate the all variables of submitted catalog item in the notifications

divyal09
Tera Contributor

How can I populate all variables in the notification from the submitted catalog item. I tried updating it with email script but the variables are not getting populated.

14 REPLIES 14

kkrushkov
Mega Sage

Hi, @divyal09 

Are you using a flow designer for that?

No, I tried updating from workflow

May I see your script, please?

(function runMailScript(current, template, email, email_action, event) {

    // Add your code here

    template.print('Variable Summary: <br/>');
   
    var ritm = new GlideRecord('sc_req_item');
    ritm.get('request', current.request_item);
   
    var variables = ritm.variables.getElements();
    for (var i=0;i<variables.length;i++) {
        var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
        if(label != ''){
            template.space(4);
            template.print('  ' + label + " = " + value + "<br/>");
        }
    }

})(current, template, email, email_action, event);