How to get Catalog task variables in approval Notification written on approval table

Sowmya
Tera Contributor

Hi Team,

Have written Notification which is triggering on approval table based on the approval triggered in the catalog task, I am not able get the catalog variables in the notification. For Example Deferal: ${sysapproval.u_servers_for_deferral} u_servers_for_deferral field is catalog task.

Can anyone help me on how get the catalog task variables printed in Notification 

Sowmya_0-1713588140652.png

Sowmya_1-1713588168374.png

 

1 ACCEPTED SOLUTION

Sujatha V M
Kilo Patron
Kilo Patron

@Sowmya  You can have a notification email script created as below and add it to your notification with mailscript syntax,

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var gr = new GlideRecord('sc_req_item');
    gr.get(current.document_id);
    //If required for specific catalog item, mention the sys id in the "If" statement
    //if ((gr.cat_item == "") 
        template.print("<b>"+"Request Details:"+"</b>"+"<br/>"+"<br/>");
        var set = new GlideappVariablePoolQuestionSet();
        set.setRequestID(current.getValue('sysapproval'));
        set.load();
        var vs = set.getFlatQuestions();
        for (var i = 0; i < vs.size(); i++) {
            if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {
				template.space(1);
                template.print("<b>" + vs.get(i).getLabel() + "</b>" + "  :  " + vs.get(i).getDisplayValue() + "<br/>");
            }
         }
})(current, template, email, email_action, event);

 

SujathaVM_0-1713588988474.png

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

View solution in original post

1 REPLY 1

Sujatha V M
Kilo Patron
Kilo Patron

@Sowmya  You can have a notification email script created as below and add it to your notification with mailscript syntax,

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var gr = new GlideRecord('sc_req_item');
    gr.get(current.document_id);
    //If required for specific catalog item, mention the sys id in the "If" statement
    //if ((gr.cat_item == "") 
        template.print("<b>"+"Request Details:"+"</b>"+"<br/>"+"<br/>");
        var set = new GlideappVariablePoolQuestionSet();
        set.setRequestID(current.getValue('sysapproval'));
        set.load();
        var vs = set.getFlatQuestions();
        for (var i = 0; i < vs.size(); i++) {
            if (vs.get(i).getLabel() != '' && vs.get(i).getDisplayValue() != '' && vs.get(i).getDisplayValue() != 'false') {
				template.space(1);
                template.print("<b>" + vs.get(i).getLabel() + "</b>" + "  :  " + vs.get(i).getDisplayValue() + "<br/>");
            }
         }
})(current, template, email, email_action, event);

 

SujathaVM_0-1713588988474.png

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.