We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Mailscript for Notification coding help required

ChrisWing
Mega Guru

Upfront my grasp of Glide and coding in general is rudimentary and working on being more proficient but it's a challenge.  What I am trying to do is display specific variables based on the Approver's ID.  This mail script is called by a notification that is specific to this one catalogue item.  What seems to be happening is the validation piece isn't working though I have no errors.  Below is the script I have (cobbled together using a couple other community posts I have seen). Variable 1 and Variable 2 were the two paths I was going down without much success but hopefully someone can guide me and it is just a small change.

(function runMailScript(current, template, email, email_action, event) {
template.print("<b>Access requiring your approval:\n</b>");
var sysapprover = current.approver;
var getvariables=new GlideRecord('sc_req_item');
getvariables.addQuery('sys_id',current.sysapproval);
getvariables.query();
while(getvariables.next())
{
 if(current.getvariables.uar_approver_1 == sysapprover){
template.print('Access Details:'+getvariables.uar_reason_1);}
 if('uar_approver_2'+getvariables == 'sysapprover'){
 template.print('Access Details:'+getvariables.uar_reason_2);}
 if('uar_approver_3'+getvariables == 'sysapprover'){
 template.print('Access Details:'+getvariables.uar_reason_3);}
}
});

 

 

0 REPLIES 0