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

Programmatic read value of custom attributes

Hi all,

i need to read custom attributes value: i wrote some code but i get always the same error ( using working copy too ):


org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValue(WorkItemImpl.java:2848)
at com.ibm.team.workitem.common.internal.attributeValueProviders.FallbackProvider.getValue(FallbackProvider.java:31)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:899)


this is my code to read the value:

		IWorkItemServer workItemServer = getService(IWorkItemServer.class);

IWorkItem workingCopyItem = (IWorkItem) wi.getWorkingCopy();
parameterString += "\"workItemId:"+wi.getId()+"|";
parameterString += "project:"+workItemServer.findAttribute(workingCopyItem.getProjectArea(), "project", monitor).getValue(iac, workingCopyItem, monitor)+"|";

IAC is IAuditableCommon
monitor is ProgressMonitor

The code is in an OperationParticipant


Thanks

0 votes



3 answers

Permanent link
Hi,
first you have to retrieve the attribute using findAttribute method, and then you have to use IWorkItem.getValue(IAttribute) method, casting the returned value (if it is an enumeration is quite more complex).

Before the getValue maybe you want to run the IWorkItem.hasAttribute(IAttribute) in order to be sure that the work-item has the attribute you need.

Best Regards,
Michele.

0 votes


Permanent link
 I have the same issue. Any one has the solution?

0 votes


Permanent link
If you use the client API this is described here: http://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

If you use a server API, here are examples http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/

You use the ID of the custom attribute to find the IAttribute.

Basically you find the IAttribute using the ID and then getValue() the value and cast it to a matching type.

0 votes

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,930

Question asked: Apr 11 '12, 8:15 a.m.

Question was seen: 5,582 times

Last updated: Sep 10 '13, 1:37 a.m.

Confirmation Cancel Confirm