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

How to read the value of an attribute of a workitem with Plain Java API?

The workitem has some attributes: Type, Tags, Task Completion, Severity, Status... I need from these the value of Status (smallstring) . I get the identifier of the Status it is internalState.
 

workItem = copy.getWorkItem();

com.ibm.team.workitem.common.model.IAttribute status = workItemClient
                    .findAttribute(workItem.getProjectArea(),
                            "internalState", null);

System.out.print(workItem.getValue(status));

I don't know why I get this Exception:

java.lang.IllegalStateException: Attempting to get unset feature: Creator at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getCreator(WorkItemImpl.java:1362) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.eGet(WorkItemImpl.java:2338) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1021) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1013) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1008) at com.ibm.team.workitem.common.internal.PropertyUtil.get(PropertyUtil.java:105) at com.ibm.team.workitem.common.internal.PropertyUtil.get(PropertyUtil.java:109) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValue(WorkItemImpl.java:2897) at Sample.analyzeItem(Sample.java:146) at Sample.analyzeReference(Sample.java:103) at Sample.run(Sample.java:91) at Sample.main(Sample.java:38)

The exception thrown when i call the getValue() function. If somebody know the problem please show some example code!

Thanks your help!!

0 votes


Accepted answer

Permanent link

Hi,

please find sample code and considerations at https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

I assume your work item was resolved using a profile that does not include the attribute. Compare this entry:
https://jazz.net/forum/questions/21082/problem-in-retrieving-creator-and-creation-date-attributes

If that is not solving the issue you are possibly getting a work item which does not have the attribute set yet. Please consider using the

if (workItem.hasCustomAttribute(customString)){
    Object value = workItem.getValue(customString);
    if (value instanceof String) {
        String attributeValue = (String) value;
        // do something with the value
    }
}
code fragment from the article.

If this answers your question please mark the answer as accepted.

- Arne

Denes Elo selected this answer as the correct answer

0 votes

Comments

Thanks! I opened the SMALL_PROFILE, now I open with FULL_PROFILE and everything works fine.

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,935
× 411
× 233

Question asked: Aug 10 '17, 8:33 a.m.

Question was seen: 3,035 times

Last updated: Aug 11 '17, 2:44 a.m.

Confirmation Cancel Confirm