It's all about the answers!

Ask a question

Programmatic read value of custom attributes

Antonio Bonanni (1011716) | asked Apr 11 '12, 8:15 a.m.
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(
at org.eclipse.core.runtime.Assert.isTrue(

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


3 answers

permanent link
Michele Pegoraro (1.8k1210398) | answered Apr 16 '12, 5:48 a.m.
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,

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 09 '13, 4:39 p.m.
 I have the same issue. Any one has the solution?

permanent link
Ralph Schoon (54.4k13641) | answered Sep 10 '13, 1:36 a.m.
edited Sep 10 '13, 1:37 a.m.
If you use the client API this is described here:

If you use a server API, here are examples

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.

Your answer

Register or to post your answer.