How to display attribute value in work item editor.
I am using setValue(IAttribute attribute, Object value) method to set value of attribute of work item.
Value is set to attribute. I verified it using getValue(IAttribute attribute) method but it is not displayed in work item editor.
I am creating operation participant for work item save operation. When work item is saved i am expecting to see value of attribute as set using setValue method, but nothing is displayed in work item editor in the text field of attribute.
One answer
You have to save the work item in the operation participant if you want to change its value. Please also note, that if you save a work item in a participant for work item save. If you don't take precaution this will trigger your participant again and..... the server will die in a recursive call crash.
See https://rsjazz.wordpress.com/?s=participant for several examples you should look at to get started.
See https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ in case you haven't already.
Comments
I am using server side java API to set value of an attribute
Following is my code snippet
IWorkItem sourceworkItem = (IWorkItem)auditable;
IProjectAreaHandle projectArea = sourceworkItem.getProjectArea();
IWorkItemCommon workItemCommon = (IWorkItemCommon)getService(IWorkItemCommon.class);
IAttribute changerequest = workItemCommon.findAttribute(projectArea, "cr", monitor); //cr is attribute id
String value = new String("one");
if (sourceworkItem.hasCustomAttribute(changerequest))
{
sourceworkItem.setValue(changerequest,value);
}
Value is not shown in work item editor.
Yes, because you don't save the work item after setting the value. My best advise is to actually ready my answer and then read the related blog posts, because they explain all that. That is the reason that I do them:
- To share with users that are interested to learn
- So that I don't have to paste the same text in questions here
So see https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ and https://rsjazz.wordpress.com/?s=participant
You will also need to get a workingcopy for the work item, because if you try to save this workmitem you will get an Exception saying the work item is immutable. Again explained in https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/