Why do I get an assertion failed when getting an attribute value using the Java API?
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
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
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.
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.
Comments
sam detweiler
Jun 21 '15, 10:50 a.m.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);