Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Jim Coyne
Kilo Patron

It's always a good idea to write and maintain the minimum amount of code as possible, so minimizing the number of Email Scripts is helpful.   But can we have just one script AND output different content based on the target audience of the notification?   You want to stay away from writing different scripts to output slightly different text, like an additional field for example, based on the target audience.   Email Scripts do not support passing parameters, which would be helpful in this scenario, but we can get around that by adding the parameter on the Notification record instead, which is where you define your target audience anyways.

First, add a new field on the Notification form:

find_real_file.png

It can be as simple as a string field or you can create a Choice List for it as well.

Create the Mail Script that will contain the text you want to output as well as the logic for supporting slightly different text:

find_real_file.png

My example is not very useful, but you get the idea.

And lastly, in the Notification record, call the Mail Script from within the HTML field:

find_real_file.png

Depending on your own use case, you could even create an Email Template that contains the default text and the call to the Mail Script to really keep maintenance to a minimum.

So when the Email Script is run, it will check the field on the Notification record and output different text based on that value.   Here's a preview of 3 different Notifications I created, all using the same Email Script, but with different values in the Custom parameter field.   They all output something different from that 1 script.

First Notification:

find_real_file.png

Second:

find_real_file.png

Third:

find_real_file.png