Forums

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

How to write a HAPI Script to execute more than one transition after each other

Nico
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 6, 2025

Hello dear community,

 

Task

I have created a script that should execute parent transitions depending on changing the state of a child.

This works fine if there is just a single transition to be executed.

Sometimes I need more than one transition in sequence (as the second transition is only valid if the first transition has been finished) and created a loop to execute these transitions:

 

[ ...listofTransitions...].forEach{ myTransition -> 
        logger.warn("State of parent issue $parentIssueKey from child $currentIssueKey must be changed to $myTransition")
        try {
            parentIssue.transition(myTransition)
        } catch (transitionError)
        {
            println("transition error: $transitionError")
        }
    }

Challenge

The first transition works always fine, but for the second there is an transition error:

transition error: com.adaptavist.hapi.jira.exceptions.issues.IssueTransitionValidationException: No such action: 'Review Design (FSDS)' available. Available actions are 'Reject', 'Execute SVT after suc. Integration Test', 'Continue Implementation'

This indicates that the first transition change has not been finished during the script execution as the listed transitions actions are valid only for the first transition.

But on the GUI I can see that the first transition was successful.

I thought I could improve this by adding a sleep function, but it seems that the transition execution is only finished when the complete script is finished.

Question
How is it possible to sync the second transition with the finish of the first transition is completely executed?

 

Your help is appreciated very much!

Best regards
Nicolas

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Mohamed Benziane
Community Champion
May 28, 2025

Hi,

Try to use the refresh methode to get the latest data of the issue

Issue (hapi 0.2.98 API)

TAGS
AUG Leaders

Atlassian Community Events