It's all about the answers!

Ask a question

How to update a custom attribute value of a workitem using server side API.


Sachin Nairy (5111017) | asked Sep 27 '13, 5:36 a.m.

 

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


permanent link
Ralph Schoon (55.5k23642) | answered Sep 27 '13, 6:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Sachin,

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.
Sachin Nairy selected this answer as the correct answer

Comments
Sachin Nairy commented Oct 29 '13, 7:00 a.m.

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.


Ralph Schoon commented Oct 29 '13, 7:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

Your answer


Register or to post your answer.