Modifying email template to include a custom attribute results in AssertionFailedException when the attribute doesn't exist in built-in types
Having read about the ability to modify the email templates in RTC (https://jazz.net/library/article/957) I thought I'd try and include one of the custom attributes in my emails. I modified the "Work item change notification" template to include:
The preview shows that the value isn't included, but I don't want to put this email template change live until I know its not going to cause errors for all the built in work item types. Where would the template error show? Is there a boolean method for testing whether an attribute exists that could be used in the #if statement rather than the get method?
Any suggestions?
Subject:Using the "Template Test" tool, I can select the custom work item types that contain this attribute and the emails are as expected. However, if I select a built in work item type, that doesn't contain the attribute, the tool shows I have an error in the template:
[Work Item ${workItem.identifier}] #if(${change.isCreation}) New: #end #if(${workItem.get("com.ibm.team.workitem.apar.aparNumber")})(${workItem.get("com.ibm.team.workitem.apar.aparNumber")}) #end ${workItem.summary} ${recipientRelation.abbreviation}
Body:
Web UI: ${workItem.URL}
Id: ${workItem.identifier}
Type: ${workItem.type}
#if(${workItem.get("com.ibm.team.workitem.apar.aparNumber")})
APAR: ${workItem.get("com.ibm.team.workitem.apar.aparNumber")}
#end
Summary: ${workItem.title}
...
Method invocation exceptionI deliberately put the workItem.get in the #if to try to test for its existence before using it to display, to try to avoid this scenario. Looking at the conditionals section of the Velocity Template language, I believe that the #if statement should evaluate to false if the value is a null value or false and then there should be no output - this is what I expected to happen if the workItem.get() expression failed.
Method get() threw AssertionFailedException: assertion failed:
The preview shows that the value isn't included, but I don't want to put this email template change live until I know its not going to cause errors for all the built in work item types. Where would the template error show? Is there a boolean method for testing whether an attribute exists that could be used in the #if statement rather than the get method?
Any suggestions?