How to update a custom attribute value of a workitem using server side API.
Hi,
I wrote a java server side API to update a custom attribute value of a workitem using below code, value is showing in console but value is not updating in work item.
public class NcbreleseClass extends AbstractService implements
IOperationParticipant
{
private IWorkItemCommon fWorkItemCommon;
public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException
{
Object data = operation.getOperationData();
ISaveParameter saveParameter = null;
if (data instanceof ISaveParameter)
{
fWorkItemCommon = getService(IWorkItemCommon.class);
saveParameter = (ISaveParameter) data;
IAuditable auditable = saveParameter.getNewState();
IWorkItem workItem = (IWorkItem)auditable;
String type = workItem.getWorkItemType();
if (type.equals("projectchangerequest"))
{
IProjectAreaHandle fprojectArea = workItem.getProjectArea();
//info is custom attribute
IAttribute infovalue = fWorkItemCommon.findAttribute(fprojectArea,"info",monitor);
String value = new String("Update");
workItem.setValue(infovalue,value);
Object crValue = workItem.getValue(infovalue);
String crstring = crValue.toString();
System.out.println("Info Value is updated...."+crstring);
}
}
}
}
Thanks & Regards
Sachin Nairy
Accepted answer
https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ shows how this can be done using the server API.