It's all about the answers!

Ask a question

How to display attribute value in work item editor.


vikrant kamble (132878) | asked Jul 16 '15, 7:41 a.m.
Hi All,
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



permanent link
Ralph Schoon (59.7k23643) | answered Jul 16 '15, 8:18 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
If you talk abut the server side Java API to set the value of an attribute in an operation participant, please note that just doing set value does not trigger any work item save operation at all.

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
vikrant kamble commented Jul 16 '15, 9:43 a.m.

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.


Ralph Schoon commented Jul 16 '15, 9:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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:

  1. To share with users that are interested to learn
  2. 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


Ralph Schoon commented Jul 16 '15, 9:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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/

Your answer


Register or to post your answer.