How to access custom attribute Contributer List
IWorkItemCommon workItemService = param.getSaveOperationParameter().getAuditableCommon().getPeer(IWorkItemCommon.class);
r = iac.resolveAuditable((IWorkItemHandle)ir.resolve(),IWorkItem.FULL_PROFILE, null);
IAttribute attribute= workItemService.findAttribute(operation.getProcessArea().getProjectArea(),"assigned_to_tasks", monitor);
List<icontributorhandle> list = (List<icontributorhandle>) r.getValue(attribute);
System.out.println("*******list************"+list);
System.out.println("*******list.toString************"+list.toString());
for (Iterator iterator = list.iterator(); iterator.hasNext(); )
{
IContributor contributor= (IContributor)iterator.next();
System.out.println("*******contributor.getName()************"+contributor.getName());
System.out.println("*******contributor.getUserId()************"+contributor.getUserId());
}
But this is not working, Kindly help
Accepted answer
2. This code works for me in A RTC WorkItem Command Line Version 3.0 :
Object current = getWorkItem().getValue(iAttribute);
if (!(current instanceof List<?>)) {
error
}
List<?> currentList = (List<?>) current;
Comments
Thank you very much Ralph
That is pretty much all the code. The rest of the code would not help you at all, because I do something quite different and the code is relatively complex.
Anyway, you iterate the list, cast the result to IContributorHandle (check instenceof first) resolve the contributor handle.
You can download the code from the post above and look into com.ibm.js.team.workitem.commandline.commands.ExportWorkItemsCommand.calculateContributorListAsString(Object, String), if you want to.
PS: If you set up your environment for debugging as explained in the workshop and posts here: https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ , you can see what is going on easily enough and see what you get.
If you don't set up for debugging, I would stay away from trying to write extensions.
Thanks Ralph!!