Forums

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

Transition Condition Script check Destination Step

Jonathan Zuber May 29, 2020

Hi,

First off I am using ScriptRunner.

I am trying to write a generic, simple script (ie: return true/false) to be used by multiple transitions . 

These will be used to set up a condition for the transition (ie: the transition will be visible or invisible based on the result).

The goal is to check if the action will lead to a particular step.  

Pseudo code:

return transition.endStep == "ABC"

The issue is I cannot (after hours of reading) find a way to access the transition the condition script is being run for. I am able to get the current step descriptor as follows:

def currendef issueManager = ComponentAccessor.getIssueManager()
MutableIssue curIssue = (issueManager.getIssueByCurrentKey(issue.getKey()))
StepDescriptor = workflow.getLinkedStep(curIssue.getStatus())

 

transientVars["actionId"is not available... (https://scriptrunner.adaptavist.com/latest/jira/recipes/workflow/get-workflow-vars.html)

getDestinationStep() is not available... (https://scriptrunner.adaptavist.com/latest/jira/behaviours-api-quickref.html#_workflow_information)

 

Thanks for any guidance!

 

Jon

1 answer

1 accepted

0 votes
Answer accepted
PD Sheehan
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.
May 29, 2020

Where are you pointing to your generic script?

If you put it in a "custom script condition", transientVars["actionId"] should be available.

It's not available in "simple scripted condition".

Then you can get the name of the target status:

ComponentAccessor.getWorkflowManager().getWorkflow(issue).getDescriptor().getAction(transientVars['actionId'].toInteger()).unconditionalResult.status
Jonathan Zuber May 31, 2020

Hi, 

 

I was trying it in a simple scripted condition... 

 

"It's not available in "simple scripted condition"." This is all I needed!

Maybe I missed it somewhere in the documentation.

 

Thanks!

PD Sheehan
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.
May 31, 2020

I don't think this is listed in the documentation, but the script editor's script info (the question mark icon) is your friend when it comes to understanding what variables are available

If it's not listed, it is not available.

2020-05-31 17_56_23-Window.png

Jonathan Zuber June 1, 2020

That' a great tip - thanks again!

Suggest an answer

Log in or Sign up to answer