It's all about the answers!

Ask a question

RTC how to update programmatically workitems?


Nicolás Rodríguez (3142125) | asked Jul 30 '12, 9:22 a.m.
 Hi

I need to update a workitem in a operationParticipant, i need to add a new subscriber.

i already retrieved the subscriber,and I got the subscription list of the workitem and added it to the list, but  the change doesnt appear in the UI, i suppose that i need a way to do a commit or save the workitem.

I m doing this in the server side, in a follow up action

2 answers



permanent link
Jared Russell (1.3k12019) | answered Jul 30 '12, 11:33 a.m.
edited Jul 30 '12, 11:33 a.m.

You will need to add the IWorkItemServer service as a dependency to your plugin if you have not already done so. Once you have added the dependency, you can save your work item using the IWorkItemServer#saveWorkItem2() method as shown below: 

IWorkItem workItem = ... 
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
workItemServer.saveWorkItem2(workItem, null, null);

Comments
Nicolás Rodríguez commented Jul 31 '12, 2:03 p.m. | edited Jul 31 '12, 3:37 p.m.

 Hi Jared


The code that you posted works when the workitem its not created, but when I am gonna used it on a created workitem i got a exception on the saveWorkItem2 method, the message its: Stale data, but i havent change the workitem, there is a way to refresh the workitem before save it?




Nicolás Rodríguez commented Jul 31 '12, 6:39 p.m.

I resolved the problem, first you need to retrive again the workItem:

wiServer = getService(IWorkItemServer.class); IWorkItem wi = (IWorkItem)wiServer.getAuditableCommon().resolveAuditable(newState, IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();

and them you can modify the work item.

and them you save it, but then its goning to appear the a great problem, the propagation, the solution for that is in the next forum https://jazz.net/forum/questions/53983/avoid-participant-propagation


permanent link
Daniel Toczala (88211514) | answered Jul 30 '12, 11:21 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
 You need to do the commit of the changes, and then you should refresh the UI, so you can see the changes.  You can see some of the more common ways of doing these things in the RTC 4.0 Extensions Workshop (https://jazz.net/library/article/1000).

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.