It's all about the answers!

Ask a question

AssertionFailedException problem with getting the values of attributes

Robert Siara (82914) | asked Nov 23 '12, 4:34 p.m.
edited Nov 23 '12, 6:56 p.m.
I have a problem with getting the values of attributes ​​(built in and custom).

I use this code to get the built-in attributes and their values.

List<IAttributeHandle> builtInAttributeHandles = service.findBuiltInAttributes(projectArea, monitor);
IFetchResult builtIn = repository.itemManager().fetchCompleteItemsPermissionAware(builtInAttributeHandles,IItemManager.REFRESH, monitor);
for (Iterator it = builtIn.getRetrievedItems().iterator(); it.hasNext();) { handle = (IAttributeHandle); attribute = (IAttribute) repository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT,new NullProgressMonitor());
System.out.println("  Built In Attribute: "+ attribute.getDisplayName());
System.out.println(" Type: " + attribute.getAttributeType());
try {
     System.out.println("  Value "+ resolved.getItem().getValue(attribute));
    } catch (AssertionFailedException e) {

But i always get AssertionFailedException ( i know that i need use different method for enumeration but even for other atributtes i get this exception)

This code I use for enumeration (borrowed from this forum)
 System.out.println(" type"+"="+attribute.getAttributeType());
 System.out.println(" value"+"="+item.getValue(attribute));
 IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>)workItemClient.resolveEnumeration(attribute, null);
 IAuditableClient iac = (IAuditableClient) repository.getClientLibrary(IAuditableClient.class);
 IAuditableClient auditableClient = (IAuditableClient )repository.getClientLibrary(IAuditableClient.class);
 String[] iaval = attribute.getValue(auditableClient, item, null).toString().split(":");
 if(iaval.length>1 && iaval[1]!=null){                                                       
 List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
 for (ILiteral literal : enumerationLiterals){
 System.out.println("attribute name="+attribute.getIdentifier() +", type"+"="+attribute.getAttributeType()+" literal="+literal.getIdentifier2().getStringIdentifier()+" literal name="+literal.getName());                                       

I will be very grateful for help

Also i have problem with format code in this post, I do not know that anyone will want to read it :/

Accepted answer

14 other answers

permanent link
Param S (276) | answered Feb 26 '21, 12:32 a.m.

 Perhaps we can get values to built in and custom attributes using RPT. The workitems can fetched faster. It supports selection and filtering fields and values. It's supports pagination as well so we can use threads to get data in bunches concurrently.

permanent link
Neha Lourenco (112) | answered Dec 01 '16, 5:56 a.m.
 What are the jars and libraries required to be included into the build path (in eclipse) to execute this code?

sam detweiler commented Dec 01 '16, 7:20 a.m. | edited Dec 01 '16, 7:23 a.m.

i execute this from Eclipse and have set up user 'libraries' for the PlainJava jar files

if you then build an executable jar, you can include the needed jars inside, or you can point to the folder where all the plainjava jars reside

there are so many, I don't know exactly which ones you can leave out.

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 16 '13, 10:36 a.m.
 Very useful for me. Thanks @sam

permanent link
Arjun Pande (3513) | answered Sep 16 '13, 1:15 a.m.

It is still showing an error like Invalid reference

can you help me with an alternative solution.

permanent link
Arjun Pande (3513) | answered Sep 15 '13, 11:49 p.m.

Still it is showing an error as an Invalid reference when I am using workItem.getValue.

Can you please give me an alternate solution?

permanent link
sam detweiler (12.5k6189201) | answered Sep 10 '13, 8:15 a.m.
should be workItem.getValue("id")

permanent link
Arjun Pande (3513) | answered Sep 10 '13, 6:31 a.m.

When I am making changes to the custom attributes it is giving me an error like this:

Changes made in the template body:

Actual Start Date:         ${workItem.get("com.acn.adt2.workitem.attribute.actualstartdate")}

where id of the custom attributes is com.acn.adt2.workitem.attribute.actualstartdate.


Method Invocation Exception:

Method get() threw AssertionFailedException: assertion failed:

permanent link
Robert Siara (82914) | answered Nov 28 '12, 6:39 a.m.
you're right. Thank You very much

permanent link
Robert Siara (82914) | answered Nov 26 '12, 8:54 a.m.
edited Nov 26 '12, 8:55 a.m.
I use Your function only for custom atributtes , therefore, this condition does not help.
Please look at my code.

permanent link
sam detweiler (12.5k6189201) | answered Nov 26 '12, 8:39 a.m.
thanks for the fix for the deprecated call.

my printAttributes can handle just custom if you add a check for

if (workItem.hasAttribute(ia))  && !ia.isBuiltin())

I have not used the getCustomAttributes() method cause I choose to loop thru all

Your answer

Register or to post your answer.