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

Elijah Aromola
Mega Sage

Is current.requested_for an email? The second parameter needs to be an email. Try something like: 

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

Chuck Tomasi
Tera Patron

You noted the sys_approval table - that's not a standard OOB table. Did you mean sysapproval_approver?

Most approvals are generic to any record so assuming there is a way to dot-walk to requested_for is asking for trouble since requested_for is only available on sc_request. Do you have logic somewhere to say "is the approval for an sc_request or sc_req_item record?) Otherwise if a change_request approval comes up, your script is going to have issues.

Let me know what you find and the correct table name where you are working on this stuff. Thanks.

Hi Chuck,

 

The correct table is "sysapproval_approver".

so we want that Approval notification  should be trigger to Requested_for also.

And Requested_for should be in CC.

Could you please tell how can we achieve that?

As I could see below code for it:

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

So how we can achieve here?

Appreciate your help!

 

Thanks,

Anupam.

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