Scriptrunner Behaviour trigger based on workflow transition/step?

Brent Webster
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 6, 2016

Is it appropriate for a scriptrunner Behaviour script to update field menu items based on workflow transition/step?

4 answers

1 accepted

0 votes
Answer accepted
adammarkham
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 7, 2016

Its fine to use them in behaviours and ScriptRunner provides methods which allow you to get this information easily.

To access action name in behaviours you can use:

def transitionName = getActionName()

 

To access workflow related information in behaviours you can use the following methods:

Workflow Information
getActionName() Returns the name of the current action if the issue is undergoing a workflow action, null otherwise.
getAction() Returns an ActionDescriptor object if the issue is undergoing a workflow action, null for EditAssign, etc.
getDestinationStepName() Returns the name of the destination step if the issue is undergoing a workflow action, null otherwise.
getDestinationStep() Returns an StepDescriptor object for the destination step if the issue is undergoing a workflow action.

You should see these methods at the bottom when editing the behaviours script.

Brent Webster
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 8, 2016

Thanks Mark.  That was easy.

0 votes
Brent Webster
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 7, 2016

I added the following code snippet which I have been successfully using in to condition groovy scripts:

    ComponentManager componentManager = ComponentManager.getInstance()
    JiraWorkflow workflow = componentManager.getWorkflowManager().getWorkflow(issue);
    transitionName = workflow.getDescriptor().getAction(transientVars["actionId"]).getName()

but the transientVars map does not exist and I'm unaware of how to create it.
Can I get the transitionName without using transientVars?

Help?

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.
April 6, 2016

If you mean field options, I don't see why not

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.
April 6, 2016

It's not clear what you mean. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events