Working with Groovy script in a workflow, is there a way to capture the Transition name/title when clicked via script?
Working on one script to trigger certain actions based on what transition was selected within a workflow. When a transition is clicked, I would like to have a Groovy script act similar to a listener by testing the "button clicked" to decide what needs to be done. Rather than having hard coded scripts per transition, I am looking to have one script that will respond accordingly.
Any assistance is greatly appreciated.
Community moderators have prevented the ability to post new answers.
So after various views and no answers, I figured it out. My main issue was what my import statements needed to included.
import com.atlassian.jira.ComponentManager; import org.apache.log4j.Category; import com.atlassian.jira.workflow.JiraWorkflow ComponentManager componentManager = ComponentManager.getInstance() JiraWorkflow workflow = componentManager.getWorkflowManager().getWorkflow(issue); def wfd = workflow.getDescriptor() def actionName = wfd.getAction(transientVars["actionId"]).getName() // test what transition "button" was clicked in the workflow if (actionName == "Test Me"){ System.out.println "Heck Yeh!" } else { System.out.println "Oh No!" } System.out.println "transientVars: $transientVars";
@Bob Where have you declared 'transientVars["actionId"]' ?
Console highlights as error this variable 'transientVars["actionId"]'.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. It's missin "as int". See below
wfd.getAction(transientVars["actionId"] as int).getName()
It works...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JiraWorkflow workflow = workflowManager.getWorkflow(issue);
String workflowName=workflow.getName();
log.debug("workflow name" +workflowName)
def wfd = workflow.getDescriptor()
def actionName = wfd.getAction(transientVars['actionId'] as int).getName()
It is throwing an exception as below.
groovy.lang.MissingPropertyException: No such property: transientVars for class:
Can you please help me
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Instead of Component Manager
ComponentManager componentManager = ComponentManager.getInstance() JiraWorkflow workflow = componentManager.getWorkflowManager().getWorkflow(issue);
you could use the Component Accessor as well.
JiraWorkflow workflow = ComponentAccessor.getWorkflowManager().getWorkflow(issue)
Works for me in a transition Script.
thanks for the previous postings
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.