It's all about the answers!

Ask a question

Unable to setValue for a custom Attribute


kishan adhi (44279) | asked Apr 10 '13, 1:47 p.m.
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



permanent link
Kevin Ramer (4.5k8183200) | answered Apr 10 '13, 3:20 p.m.
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.

Comments
kishan adhi commented Apr 11 '13, 8:39 a.m.

It didn't work using the logic you gace


permanent link
Ralph Schoon (63.1k33645) | 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,
Thanks for the reply
Your suggestion worked partially
I used 1 of your method in the link
i.e. 

private static Identifier getLiteralEqualsString(String name, IAttributeHandle ia)
 

This method only returned me the literal ID for scenario 2(com.ibm.team.workitem.common.model.ILiteral:cmoCategory.literal.l3 ) where else it dint return anything at all for the Scenario 1
workItem.getValue(iAttribute1).toString();  returns  affected_environments.literal.l1

please help me out how to get value from the custom attributes for scenario 1

Thanks
for your time


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 .
Any other suggestion?
Thanks


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. 


Ralph Schoon commented Apr 11 '13, 1:05 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post 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.