Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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


0 votes



2 answers

Permanent link
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.

0 votes

Comments

It didn't work using the logic you gace


Permanent link
 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.

0 votes

Comments

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

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.

This code only works for scenario 2 did not return any value for the first scenario .
Any other suggestion?
Thanks

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. 

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 35

Question asked: Apr 10 '13, 1:47 p.m.

Question was seen: 8,485 times

Last updated: Apr 11 '13, 1:05 p.m.

Confirmation Cancel Confirm