How to get Requested_for in CC in Approval reminder email notification?

anupampatial
Giga Contributor

I have Approval notification (sys_approval) table.

I want to add "Requested_for" in CC of notification.

I have gone through docs and could find email_script:

//email.addAddress(type, address, displayname);

email.addAddress("cc", "john.copy@example.com","John Roberts");

So I have tried to write something like below:

email.addAddress("cc",current.getValue('requested_for'),current.getValue('name'));  

 

But I am here confused like table is sys_approval and we are expecting Requested_for on CC field.

 

So Can anyone help me out with this requirement.

Appreciate any quick help!!

Thanks,

Anupam.

1 ACCEPTED SOLUTION

You will need to add that code to mail script that is included in the Approval notification mail body.

Ensure your mail script checks that current.tableName() == 'sc_request' before adding the email.address() line to avoid errors. These docs should help you get started and provide some examples of email scripting.

Scripting for email notifications

View solution in original post

6 REPLIES 6

HI @Chuck Tomasi :  I am able to achieve my goal, Just sharing what i have done for my case:

As my Approval Reminder Notification was getting trigger on "SysApproval_approver" table.

 

So I have created 1 Email Script:

var ref= current.document_id.request.requested_for.email;

email.addAddress("cc", ref);

 

And I have called this mail script in body of my Approval reminder notification.

Hence I am able to Send Email to Requested_for in CC.

 

Many Thanks,

Anupam

 

 

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Like Chuck already mentioned, verify the table.

I would expect, if it's approval, it's about table "sysapproval_approver". On that table, there's no "Requested_for" field. There is a "approver" field. Or you could dot walk to the task which the approver is about, through the "sysapproval" field.

email.addAddress("cc", "john.copy@example.com","John Roberts");

Is indeed the example which should work fine.

Do note: when testing on your PDI or company DEV instance, and having a overwrite mail adres set (System Property glide.email.test.user): the CC will not be populated! So be aware of that while testing, it might be confusing. Though, without overwrite mail adres set: works fine.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn