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.
Comments
Thanks Ralph, It is a good information which u shared. it helps a lot to understand rtc framework. if possible write some information about coding standard for rtc api which will help us to avoid server load while running plugin.
I have posted what I know in my blog.
To reduce load reduce the attributes you load by using profiles. Also detect as quickly as possible if you have to do something and quit if not. Avoid complex searches if possible. But finally, if you have to do something, you have to do it. No way around it. You could only try to reduce load by using intelligent algorithms and things Java Provides such as hash maps etc.