Why do I get an assertion failed when getting an attribute value using the Java API?
Bruno Fazoli (8●5●6)
| asked Jun 21 '15, 9:43 a.m.
edited Jun 21 '15, 10:45 a.m. by Ralph Schoon (63.3k●3●36●46)
Hi guys,
I would like to understanding an error that I'm getting. I have a custom workitem type on my RTC instance, and I have an java application that read the workitem attributes and connect to an ERP system to perform some actions. I've noticed that If I have some workitems already created and I add a new custom attribute on the workitem configuration, the java application tries to find it on these already created workitems an return "assertion failed" stack trace. For new workitems I don't have this erros. If I delete these "old' workitems and create new ones, I don't have this problem as well My question is: How can I manage this behavior? Imagine I have many workitems already cretead and I need to update or add a new custom attribute, I cannot delete and create all workitems again, it is not viable. Should I have to create some pre-define custom workitems attributes and reserve them for future use avoiding creating new attributes? Thank you in advance |
One answer
Ralph Schoon (63.3k●3●36●46)
| answered Jun 21 '15, 10:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jun 21 '15, 10:04 a.m.
If you want to read an attribute use hasAttribute() first and only try to getValue, if there is one. See https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/
You can also, in the Eclipse admin when creating the new attribute check for its usage and thus Synchronize the attributes ti the old items. Anyway, always safer to check if it has the attribute, before trying to load it. |
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.
Comments
attributes are a PROJECT wide thing.. any workitem COULD have one of the attributes. In addition, adding attributes after workitems are created does NOT automatically force those attributesonto the old workitems. (you need to synchronize the old workitems to do this)
as Ralph mentions, there is a method to determine IF a workitem has that attributes
boolean IWorkItem.hasAttibute(IAttribute);