Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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



 

0 votes


Accepted answer

Permanent link

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

0 votes

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. 

Billion Thanks  Ralph . It is Worked for me. 

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

1 vote

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,943

Question asked: Sep 20 '18, 1:47 a.m.

Question was seen: 1,649 times

Last updated: Sep 20 '18, 9:35 a.m.

Confirmation Cancel Confirm