Unable to setValue for a custom Attribute
Hi,
i am using plain java API to get connected with RTC from eclipse. I have n number of custom attributes. Some of them I can set value using the literal value ( workItem.setValue(attrWic,"ILiteral:cmoCategory.literal.l4");) but some I am not able to set the value When I do getValue i get different scenarios. Scenario 1 workItem.getValue(iAttribute1).toString(); returns affected_environments.literal.l1 Scenario 2 workItem.getValue(iAttribute2).toString(); returns com.ibm.team.workitem.common.model.ILiteral:cmoCategory.literal.l3 Anything that has output like scenario 2 I am unable to setValue() I am getting following error message Exception occurred during playback of script [Script1] [CRFCN0019E: RationalTest ScriptException on line 48 of script Script1 - java.lang.ClassCastException: jav a.lang.String incompatible with com.ibm.team.workitem.common.model.Identifier.]. Please suggest me how to set value for such custom attributes. Thanks |
2 answers
My experience is that the literal ID follows the colon (:) in the result of workItem.getValue(iAttribute2).toString()
Look at your Process Source for the enumeration. You're likely to find id="cmoCategory.literal.l3" but not the other. So try split(":") to get the parts, use the 2nd for the value to workItem.setValue() method. |
Ralph Schoon (63.3k●3●36●46)
| answered Apr 10 '13, 3:47 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
There is some code that might help here: https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/ . I am not sure what the issue is.
Comments
kishan adhi
commented Apr 11 '13, 8:44 a.m.
Hi Ralph,
private static Identifier getLiteralEqualsString(String name, IAttributeHandle ia)
Ralph Schoon
commented Apr 11 '13, 11:08 a.m.
| edited Apr 11 '13, 11:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I am not sure I understand what you are asking. You need to cast to the correct thing. If you getValue(IAttribute) on an enumeration type attribute you get an Identifier.
Object prio = workItem.getValue(priority); if (prio instanceof Identifier<?>) { Identifier<?> identifier = (Identifier<?>) prio; System.out.print("\tIdentifier: " + identifier.getStringIdentifier()); }The code gets the identifier and you would have to look up a display value analog to the way it is described in the post. I am not aware of an easier way - which does not mean there is none that I haven't found.
kishan adhi
commented Apr 11 '13, 12:54 p.m.
This code only works for scenario 2 did not return any value for the first scenario .
Ralph Schoon
commented Apr 11 '13, 12:58 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Scenario 1 does not make sense to me, so you might want to be more explicit about the use case and what you want to achieve. You might also want to read http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and search for Casting... |
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.