It's all about the answers!

Ask a question

Modifying a workitem with IOperationAdvisor or IOperationParticipant ?


John Kelly (1231715) | asked Oct 22 '12, 8:37 a.m.
 Hi,

I was looking for a way to change the value of a workitem's attribute during the Save phase.
In com.ibm.team.process.common.advice.runtime there are 2 hooks, namely IOperationAdvisor (pre-save) and IOperationParticipant (post-save). I've looked around for some examples of workitem modification, but haven't found any yet. It's not even clear to me if i makes sense to be able to make a change on a workitem during the either pre-save or post-save phase. Would someone please advise? 

thanks in advance
John

Accepted answer


permanent link
Ralph Schoon (63.4k33646) | answered Oct 22 '12, 9:49 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 22 '12, 9:49 a.m.
Hi John,

here is an example participant: http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/

I would probably use a participant rather than an Advisor, however, I know others have done modifications in an Advisor as well. You might also want to look if you can use a java script based extension e.g. a calculated value provider https://jazz.net/wiki/bin/view/Main/AttributeCustomization .
John Kelly selected this answer as the correct answer

Comments
John Kelly commented Oct 22 '12, 10:08 a.m.

Thanks so much for your prompt response Ralph... 


I had a look at the example and it appears to update the parent of the workitem-being-saved, is it valid to modify the workitem-being-saved itself? I will also check out the attribute customization, which may well help...

thanks again
John 


Ralph Schoon commented Oct 22 '12, 10:16 a.m. | edited Oct 23 '12, 2:15 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Hi John,

Update

You should use a Participant/followup action to modify a work item, not do it in a precondition.

Update

Old Answer
I am aware of the difference and have thought about its implications. I would assume that it is save to modify and save the work item itself in the precondition. What will happen is that the save triggers the preconditions again. So you might want to pass a cue that the precondition is triggered by a prior precondition save (as described in the example).

Other than that, I would be more concerned about what the user sees in the UI. Does it refresh the change? I have not done this myself, but I would definitely try it out - on a test system as described in the Extension workshop

Old Answer

Please, can you share your experience here?


3 other answers



permanent link
sam detweiler (12.5k6195201) | answered Oct 22 '12, 4:04 p.m.
Ralph I really think that this is a bad idea. . the Advisor (preCondition) should never ever modify anything.
you should change your answers in the future here..

Changes should be done by the Participant. cause thats what it is/does.. it participates in the transaction.
both will fire the save event handler again.

Sam

Comments
Jared Burns commented Oct 22 '12, 5:19 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

+1. Preconditions shouldn't make modifications to the data.


Ralph Schoon commented Oct 23 '12, 2:19 a.m. | edited Oct 23 '12, 2:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Sam, Jared thanks for the hints. I updated the answer with your input.

Are there any underlying reasons/implications why? The reason why I am asking is that there are other activities going on before the save. For example value providers.

I am aware that precondition really says condition - which is a test and not a manipulation. However, I can see reasons why someone would want to modify items before they are saved. For example to set dependent values. I am also aware that there are value providers available and you can create such extensions. They only appear to be much more complex than Advisors.


permanent link
SEC Servizi (97123860) | answered Oct 10 '13, 11:06 a.m.
the Advisor (preCondition) should never ever modify anything. Changes should be done by the Participant. cause thats what it is/does.. it participates in the transaction. 
We have an advisor which has to retrieve information from an external database to validate the current work-item action. Some of this information has to be saved into custom attributes of the work-item, too.
Could we modfiy the operation data of the advisor to avoid to retrieve this same information even on a participant?
Thanks in advance.

permanent link
Ralph Schoon (63.4k33646) | answered Oct 10 '13, 12:10 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see: https://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/

And I don't think you can save the data. There are some mechanisms available to communicate e.g. in a participant, but I believe you would have to create your own solution in your case.

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.