Forums

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

Transiting issue in a post function script

Siavosh Kasravi
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.
April 9, 2019

Suppose I have an issue P which is going from state A to B. In this transition there is a post function that check an external condition. Based on that it may leave P to reach to B or send it to C which is another state.

There is a transition from B to C.

 

What is the best way to do it?

1 answer

1 accepted

0 votes
Answer accepted
Antoine Berry
Community Champion
April 10, 2019

Hi @Siavosh Kasravi ,

You can do that in groovy indeed : 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.util.JiraUtils


int transitionId = 51
String currentUserKey = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser().getKey()

WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
workflowTransitionUtil.setIssue(parentIssue);
workflowTransitionUtil.setUserkey(currentUserKey)
workflowTransitionUtil.setAction(transitionId);
workflowTransitionUtil.progress();

Assuming 51 is the transition id between B and C. You can use this script in the postfunction of the transition from A to B (make sure put it at the last place).

Antoine

Siavosh Kasravi
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.
April 10, 2019

Thank you. Is there a reference for more explanation of API usage?

Like Antoine Berry likes this
Antoine Berry
Community Champion
April 10, 2019
Siavosh Kasravi
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.
April 12, 2019

Thanks. But is there a documentation more tutorial or guide like? Explaining the whole system and available APIs?

Antoine Berry
Community Champion
April 15, 2019

Sure, Scriptrunner has a well detailed documentation. See here, lots of examples. You can always find more if needed on the atlassian community.

Antoine 

Like Siavosh Kasravi likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events