Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Add approver name in notification

avinashdube
Tera Guru

I Have a requirement to print the approver name in the notification, i have creation notification on sc_req_item , using a email script to achieve the result but it is not working :

 

Email script:


    if(stateRitmNumber == "requested")
    {
       template.print("<br><br><Strong>State : Pending Approval of ${approver} </Strong> "  +approverName);
    }
    else
    {
    template.print("<br><br><Strong>State : </strong>" + stateRitm);
    }
1 ACCEPTED SOLUTION

Anirudh Pathak
Giga Sage

Hi @avinashdube ,

Please use the below code in your email script to get the approver name - 

var approverName = '';
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval',current.sys_id);
app.query();
if(app.next()) {
approverName = app.approver.getDisplayValue();
}
template.print(approverName);

View solution in original post

3 REPLIES 3

Anirudh Pathak
Giga Sage

Hi @avinashdube ,

Please use the below code in your email script to get the approver name - 

var approverName = '';
var app = new GlideRecord('sysapproval_approver');
app.addQuery('sysapproval',current.sys_id);
app.query();
if(app.next()) {
approverName = app.approver.getDisplayValue();
}
template.print(approverName);

Shailesh Kumar1
Tera Contributor

Please use this script to fetch the approver...

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
    var approver = "";
    var d = new GlideRecord("sysapproval_approver");
    d.addQuery('sysapproval', current.sys_id);
    d.query();
    if (d.next()) {
        approver = d.approver.getDisplayValue();
    }
    if (stateRitmNumber == "requested") {
        template.print("<br><br><Strong>State : Pending Approval of ${approver} </Strong> " + approver);
    } else {
        template.print("<br><br><Strong>State : </strong>" + stateRitm);
    }

})(current, template, email, email_action, event);
 
It works for me
ShaileshKumar1_0-1708930728760.png

 

piyushsain
Tera Guru

Hi @avinashdube 

Use the below script 

if (stateRitmNumber == "requested") {
    var approver = '';
    var approverGR = new GlideRecord('sysapproval_approver');
    approverGR.addQuery('sysapproval', current.sys_id);
    approverGR.query();
    if (approverGR.next()) {
        approver = approverGR.approver.getDisplayValue();
    }
    template.print("<br><br><Strong>State : Pending Approval of ${0} </Strong> " + approver);
} else {
    template.print("<br><br><Strong>State : </strong>" + stateRitm);
}
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
Piyush Sain