Email Notification Script

Ken83
Mega Guru

Hello Community,

        I'm doing some re-factoring on my email notifications and I've come across a scenario where I have 2 notifications on the same table(sc_task) for the same reason but with different recipients because the information is slightly different(1 or 2 lines difference). These 2 emails can use the same email script but there is   1 roadblock here. Is there a way for me to determine, in the email notification script, who the recipient of the notification is?

Ive tried using the email_action object but many of the properties inside are empty. Here is a small snippet of the properties i looked at...

find_real_file.png

1 ACCEPTED SOLUTION

Jim, great content and useful as expected. The method that you outlined in that post is a little more complicated than I need for my situation however, you brushed right over EXACTLY what I was looking for. Here...


find_real_file.png


The email_action object provides access to 3 properties to obtain the recipients of the email notification..



find_real_file.pngis accessed via email_action.getValue('recipient_fields') and correlates to this field on the email notification record


find_real_file.png



find_real_file.pngis accessed via email_action.getValue('recipient_groups') and correlates to this field on the email notification record


find_real_file.png



find_real_file.pngis accessed via email_action.getValue('recipient_users') and correlates to this field on the email notification record


find_real_file.png



That drawn out explanation was mainly for anyone else who finds this article but, I was not aware of I could access the properties of the email_action object that way because when logging it, those values are empty but when I use .getValue(), they actually return values. Anywho, that gives me what I need to continue my consolidation efforts. Thanks everyone for the assist here!


View solution in original post

11 REPLIES 11

Tim Deniston
Mega Sage
Mega Sage

I don't know that the email's recipients are available to you. I would recommend checking the same conditions on "current" from the mail script that determine the recipients in the first place. That should give you the information you need.


Can you give me an example of what you're referring to? If you are referring to the same conditions that I am using to trigger the email notification, those are not available in the mail script using current as there is no reference of previous from the mail script, thus preventing me from checking if current.work_notes.changes


You are right... I don't think current.work_notes.changes() would be available in a mail script.  




Is this an event-based notification or condition-based? If it's event, you could use a parameter (event.parm1 or event.parm2).  


The vast majority of these are condition based. Its not the worst thing if I can't access the recipients, it would just be very beneficial in consolidating these mail scripts.