It's all about the answers!

Ask a question

How to display attribute value in work item editor.

vikrant kamble (1322596) | 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 (62.7k33643) | answered Jul 16 '15, 8:18 a.m.
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 for several examples you should look at to get started.

See in case you haven't already.

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))

Value is not shown in work item editor.

Ralph Schoon commented Jul 16 '15, 9:48 a.m.

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 and

Ralph Schoon commented Jul 16 '15, 9:59 a.m.

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

Your answer

Register or to post your answer.