How to express a Transition Issue post function condition?

Morgan Thunder April 15, 2016

I would like to set up a post function on a workflow that transitions an issue to a different status if the priority is 'high' or 'emergency'.I have added a post function of type 'transition issue' and chosen 'conditional execution'

 

The project code is TSP. It's important that I include the code in the condition as other projects use this workflow. For the condition I've tried:

(issue.getProjectObject().getKey() = "TSP") && (issue.priority?.name == 'High'||'Emergency')

 

but it doesn't work. Can anyone help me to get the syntax of the condition right and this post function working?

2 answers

2 votes
Jeremy Gaudet
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 15, 2016

At a casual glance, you want to replace "issue.priority?.name == 'High'||'Emergency'" with "['High','Emergency'].contains(issue.priority?.name)".

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 17, 2016

Or 

issue.priority?.name in ['High','Emergency']

which reads a bit more like spoken language, to me.

Like Paweł Panek likes this
Morgan Thunder April 18, 2016

Alas I have tried both:

(issue.getProjectObject().getKey() = "TSP") && (['High','Emergency'].contains(issue.priority?.name))

 

and

(issue.getProjectObject().getKey() = "TSP") && (issue.priority?.name in ['High','Emergency'])



but neither have worked. sad

 

Morgan Thunder April 18, 2016

I wonder is there some problem with the fact that the post function is on the create transition?

Jeremy Gaudet
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 18, 2016

It shouldn't be; the one time I've actually used this, it was on 'create', to transition to "Open" if the submitter was a developer.

Jeremy Gaudet
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 18, 2016

Oh, it should be "==", not "=", for the first half of your condition.  Missed that one.

Morgan Thunder April 18, 2016

Unfortunately that doesn't work either:

Tried 

(issue.getProjectObject().getKey() == "TSP") && (issue.priority?.name in ['High','Emergency'])

but no luck. It doesn't throw an error or anything, just doesn't perform the transition when I create and set priority to 'High' or 'Emergency'. In any case, I had already tried without the first part to just try to get the priority bit working and even that on its own won't work.

The only other thing I enter in is the transition number from the workflow and can't see how that can be a problem.

At a bit of a loss!

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 18, 2016

Can you attach a screenshot of the configuration, because I've lost track of what you're trying to do...

Morgan Thunder April 18, 2016

I am trying to have issues that are created and give a priority of 'High' or 'Emergency' be transitioned to another status in the workflow (in this case, not 'Open' but a status after that).

I am using a post function on the create step of type 'Transition Issue' with a condition. Here is a screenshot.

TransitionPostFunction.png

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 18, 2016

two in two minutes. that's not ScriptRunner, it's JIRA misc workflow extensions IIRC.

Morgan Thunder April 18, 2016

Oh.

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 18, 2016

Not that I would mind answering general questions, it's just originally you used the ScriptRunner labels. And JMWE has a different api (issue.get) that I'm not familar with.

0 votes
Morgan Thunder April 27, 2016

For anyone who stumbles on this, I eventually found the answer thanks to Innovalog support - the syntax that finally worked for me was:

 

issue.get("project").getKey().equals("TSP") && ["High","Emergency"].contains(issue.get("priority").name)

 

 

 

 

Rodrigo Nunes October 30, 2018

how can I get this same code to pick up the previous or previous status?

Suggest an answer

Log in or Sign up to answer