How to show requested item variable in custom approval notification

Rajveer
Tera Expert

Hello Experts,

I have created one custom approval notification for the requested item. The requirement is that I have to show some variables of the requested item in the approval notification. We can do an email script.

Could help me in this case.

 

 

 

 

 

1 ACCEPTED SOLUTION

@Rajveer 

It has worked earlier when I shared solution

Adding RITM Variables in Approval Mail Notification

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

yes you need to use email script for this

for notification on sysapproval_approver table do this

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

    // Add your code here

    template.print('RITM Variables: <br/>');

    var ritm = new GlideRecord('sc_req_item');
    ritm.get(current.sysapproval);
    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 != '' && value != ''){
            template.space(4);
            template.print('  ' + label + " = " + value + "<br/>");
        }
    }

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

Regards
Ankur

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

Hi Anukar,

Thanks for the reply.

I want to show some variables on approval notification.

Could you help me, this script work for that?

 

Hi,

if your notification is on sysapproval_approver table the above will work

You will have to handle the case if RITM has MRVS inside it

the above script won't handle MRVS; you need to enhance it

Regards
Ankur

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

@Rajveer 

It has worked earlier when I shared solution

Adding RITM Variables in Approval Mail Notification

Regards
Ankur

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