Forums

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

JIRA expression - workflow condition using customfield

Mathieu Roos April 4, 2022

Hi there,

I am really stuck so I hope you can help me.

My case should be simple : 

  • I created a select list multiple choices custom field (values : a, b, c)
  • In my workflow, I would like to add the following condition
    • if b is part of the selected items --> "approval" state is the only next state option available
    • if b is not part of the selected items --> "resolved" state is the only next state option availbale

To achieve this, I have tried, in the WF, to use the ScriptRunner Script option of the transition conditions but I didn't succeded in having it correct.

What is the best way to make this comparison?

Thanks in advance,

Enjoy :-)

Mathieu

1 answer

1 accepted

0 votes
Answer accepted
Oliver Siebenmarck _Polymetis Apps_
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 4, 2022

Hi @Mathieu Roos ,

I guess there might be multiple solutions to your case, but here is what I would do: Create two different transitions, one for getting to the "approval" state and one for "resolved".

You will then need to add a condition on each transition, so that only the correct transition is shown.  In your example (with the multi-select field) you'll want to use an expression like this one to check if an option is or is not part of the selected items.

Let's say your field id is 12345 and you want to check if "b" is selected, you would use this expression on the "approval" transition:

issue.customfield_12345.filter(f => f.value == "b").length != 0

 The next step is just as easy, simple negate the previous expression and put it onto the "resolved" transition:

!(issue.customfield_12345.filter(f => f.value == "b").length != 0)

And that's it. 

Hope that helps,
 Oliver

Mathieu Roos April 5, 2022

Hi Olivier,

Works great, thanks a lot !

Have a nice day

Mathieu

Suggest an answer

Log in or Sign up to answer