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:
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: 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. 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? |
One answer
Worked around the problem, by testing for the specific work item type:
Id: ${workItem.identifier} Type: ${workItem.type} #if($workItem.type == "APAR") APAR: ${workItem.get("com.ibm.team.workitem.apar.aparNumber")} #end Summary: ${workItem.title} |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.