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?
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
Thank you. Is there a reference for more explanation of API usage?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, the javadoc is available online. See for example : https://docs.atlassian.com/DAC/javadoc/jira/reference/com/atlassian/jira/workflow/WorkflowTransitionUtil.html
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. But is there a documentation more tutorial or guide like? Explaining the whole system and available APIs?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure, Scriptrunner has a well detailed documentation. See here, lots of examples. You can always find more if needed on the atlassian community.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.