Velocity - Add addressees email address to text Custom Field

Important - This is only meant for auditing purposes for example; adding the list of recipients from the original email related to creating the issue. This script should not be used for Custom Fields that are intended to be set for JEMH Notifications as this may incur duplicate notifications.

General scenario

If users want to set email addresses within addressee headers, i.e to, cc, to a text Custom Field, the following example script will give you a generic solution.

Important - The use of a single line Text Custom Field will have a limit on the number of email addresses that can be stored due to the character limit that single line Text Custom Fields have. To store more data, use another type of Custom Field.

Example 1 - Cc addresses

Test Case

Script

#foreach ($address in $ccAddresses) $address #end

Result

Example 2 - To addresses

Test Case

Script

#foreach ($address in $toAddresses) $address #end

Result

Example 3 - To and Cc addresses

Test Case

Script

To: #foreach ($toAddress in $toAddresses) $toAddress #end Cc: #foreach ($ccAddress in $ccAddresses) $ccAddress #end

Result

 

Extended scenarios

Adding value to Single line Custom Field

If users wants to display this information in a text single line Custom Field separated by commas, the script requires some more work, the following example script will give you a generic solution:

Test Case

Script

Velocity returns a boolean output value when adding a value to a list to display whether the addition was successful or not. You can avoid this by wrapping the addition of the value to the list within a variable assignment, e.g. #set($updatedCcAddresses = $allCcAddresses.add($address))

Result

Filtering Catch Email Address

If you wish to not include the Catch Email Address, then script would need expanding to check each address if they match a Catch Email Address and if so then do not add to the field. Below is an example for a single line text Field:

Test Case:

Script

Result