Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Execute a groovy script AFTER the transition

Bastien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

Hi,

I've got a problem during my transitions :
I wrote a groovy post-function script that is executed during the closed transition of a child issue.
This script has to verify if all the other children of its mother are closed. If they are, the mother is put into a new status (and the current child close), otherwise, just the current child is closed.

But I have another requirement : when a user wants to put the mother into the new status (the same as precedent), a transition condition has to verify if all the children are closed.

So, the first script works, but when i add the second one into the mother new status transition, and when i want to close a child, the first script cannot put the mother into the new status because the second script detects a child not closed (the child is not closed yet).

How could i do ?

Thanks !

Regards.

2 answers

1 accepted

1 vote
Answer accepted
Bastien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2012

I found a solution :

My first script (executed in the child close transition post-function) was executed BEFORE the issue passed in closed state. And that why the other script, executed when the mother have to be put in its new state detected the child not closed.

So, i put the first script in a transition condition to leave the closed state (i've got an administrator state in the child workflow, that be able to go everywhere from anywhere ...). Finally, the script is exetuted AFTER the child passed in closed status, and the mother script detects the child closed.

Congratulations, that's it

Have a chocolate!

Thank you Jamie for your answers :)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2012

Cool, well done. Enjoy that chocolate ;-)

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

I can't really get my head around your problem. Have you written your own code?

Perhaps you could use either or both of https://studio.plugins.atlassian.com/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Allsubtasksmustberesolved and https://studio.plugins.atlassian.com/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Transitionparentwhenallsubtasksareresolved.

Is what you are saying that, when you close the subtask, the parent should also close, but it doesn't because your condition is saying a sub-task is still open? If so try changing the order of events, make your post-function on the child run last.

Or you could detect if a post-function is running and ignore the condition, maybe by making the condition only valid for non-admin users, or by setting a session variable or thread-local or something. I'm sure there is an easier way than that though.

Bastien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

Thank you for your quick answer.

Is it easy to define a session variable ? I think it's the best way to solve my problem ...

Bastien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

Is what you are saying that, when you close the subtask, the parent should also close, but it doesn't because your condition is saying a sub-task is still open?

Yes it is. My child post-function script verifies if all other mother children are closed, and if it's true, it closes the mother. But in the close transition of the mother, there is a script condition that verify if all children are closed : so the first script calls the second (when all other children are closed) but the second script detects an opened child (the child who wants to be closed).
So i want my first script (post-function script on the child close transition) executed AFTER its status changement, because when the second script will be called, it will detects the child closed, and not opened ...

Bastien
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

Sorry for the triple post ... :)

Jamie, I could use the ScriptManager, and get the current scripts (I suppose there is a getScriptObjects() method, or something), test it (is there 2 scripts running ?) and then make the condition non-valid, right ?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 26, 2012

If the post-function is really the LAST post-function, you should not get this problem. Is it last?

Other methods are too complicated, and are working around an issue you should not really have, as far as I can tell.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events