How can I write a Jira expression for a field that could have multiple values?

Karen Sterkowicz June 14, 2022

I'm attempting to write a Jira expression to use in Build-your-own (scripted) Validator in my workflow. I want an error message to appear during the transition, on the transition screen, when a specific Fix Version is present. I've come up with the following expression, which works correctly to return false if the Fix Version is not 16.x.x.

!!issue.fixVersions && issue.fixVersions.some(it => it.name != "16.x.x")

Result: false

Unfortunately Fix Version can have multiple values and if I have 16.1.1 and 16.x.x and I run the same expression, the result is true.

What do I need to do differently in my Jira expression to return false if 16.x.x is present at all, regardless of the other Fix Versions? Is it even possible in JMWE or is there another validator option that comes standard with Jira?

2 answers

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.
June 14, 2022

Hi @Karen Sterkowicz ,

If I understand you correctly, you want an error message to appear (the validator to fail) whenever any of the fix versions is exactly "16.x.x". In that case, I would use the filter() function, which can make the whole expression much smaller:

issue.fixVersions.filter(it => it.name == "16.x.x").length == 0

 This expression will return true, unless 16.x.x is one of the Fix Versions. It does not matter whether you have no Fix Versions, one or multiple Fix Versions applied. 

Cheers,
 Oliver

Karen Sterkowicz June 15, 2022

@Oliver Siebenmarck _Polymetis Apps_ This is exactly what I needed. Thank you very much for the assist.

Karen

0 votes
Andrea Pannitti
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.
June 14, 2022

Hi @Karen Sterkowicz ,

you could try with this JQL:

fixVersion is not EMPTY AND fixVersion in ("16.0.0","16.0.1", ...)

with all Fix Versions you want in parentheses.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events