Modifying Work item through An RTC advisor on Deliver operation
Hi All,
I am Writing an Advisor which will be invoked while delivering a change set which is having a valid associated task with all required approvals. So here,Once Changeset is delivered ,I need to Increment a value of a field(Integer type) .SO while Setting value to this field I am getting ImmutablePropertyException .Can you please suggest me Idea to achieve this. This is the code
Integer i = (Integer) associatedWorkItem.getValue(noOfTimesRestructureFilesDeliveredAttr);
associatedWorkItem.setValue(noOfTimesRestructureFilesDeliveredAttr, i+1);
|
Accepted answer
Ralph Schoon (63.4k●3●36●46)
| answered Sep 20 '18, 2:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Sep 20 '18, 2:10 a.m. For almost all objects in RTC it is required to get a working copy that then allows the modification. See https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ for how that works for a work item in the server API. You might want to search that blog for more information related to Java APIs and how to use it. The relevant code is shown below. // Get the full state of the parent work item so we can edit it IWorkItem workingCopy = (IWorkItem) fWorkItemServer.getAuditableCommon() .resolveAuditable(workItem, IWorkItem.FULL_PROFILE, monitor) .getWorkingCopy(); Jagadeesh Marada selected this answer as the correct answer
Comments Note that you are NOT supposed to do something like this in an Advisor.
An advisor advises - and potentially blocks the operation. Modification of data is supposed to be done after the operation in a participant/follow up action.
Jagadeesh Marada
commented Sep 20 '18, 5:28 a.m.
Billion Thanks Ralph . It is Worked for me. 1
To follow up on Ralph's response. Another reason why it doesn't make sense to do this in an advisor is that in theory multiple advisors may be triggered on the operation. So you may end up writing data in your advisor (ex: update a work item), only to have some other advisor run afterwards which invalidates/cancels the operation, leaving your system in an inconsistent state (assuming your 'write' operation is depending on the trigger operation completing successfully).
|
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.