Hi all,
I am trying to modify the mail content and switch to batched emails instead of single mails for every update.
Following the guide (Adding custom fields to email (atlassian.com))
Under step 2, HTML format, step 4, we can see the following listed:
#set ($customfield = $customFieldManager.getCustomFieldObject("customfield_10000"))
This appears to be not working for batched mails as I am not getting any response out of this.
I understand, that in batched emails, we can access the custom field values as follows:
#foreach ($value in $customFields)
#if(${value.getValue()})
$escape.apply($value.getValue())
#end
#end
This is working fine, however, in case of Asset objects, I am getting an array back and also including the key.
Is it possible to get the labels only in this case?
Thanks!
Stefan
Even if I did not find a way to access the labels directly, I have managed to display the values only and also remove the [ ] around the array values.
This is how I solved it in the template:
<tr>
<td class="updates-diff-label">
$escape.apply($value.getName()):
</td>
#set ($val = $value.getValue().replaceAll("\s*\([A-Za-z]+-\d+\)",""))
<td class="updates-diff-content">
#if(${val.startsWith("[")})
#set ($val = $val.replaceAll("^\[|\]$", ""))
#end
$escape.apply($val)
</td>
</tr>
Essentially, I first replaced all object keys in the first set directive using regex.
After this, if the string starts with a [, I am replacing the first [ and the last ] also using regex.
Using the classes for the td tags allows to catch up with the existing format of batched emails.
This works like a charm.
Hope this helps others as well :)
Stefan
Hi Stefan,
Labels are in itself an array of values
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dick,
thanks for letting me know. Do you know, how I can access those within the velocity template?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.