Forums

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

JMWE Validator Condition

Yoann LEGRAND
Contributor
May 6, 2024

Hi Team, 

I have a use case , I cannot find to create a good validator with JMWE in Jira Cloud on Create transition.

I would like to allow ours users to create an issue only on specifics combinaisons of a CF(Select list) and Components.

I use JMWE with this validators : "Build-your-own Validator"

CF_AComponentResult condition
select listAB
000True
001True
010True
011True
100True
101False
110False
111False


(My Validator is on field issue Type :  if issueType = Bug => block ...and we are on Bugs's Workflow.
So if condition return True => Block , if condition return false, we skip the validator and user can create the issue)


So for exemple: 
If my Selectlist  = "0" and I have component = "A" , my condition return "True" 
So my Validator block the creation

If my Selectlist  = "1" and I have component = "B" , my condition return "False" 
So my Conditional validation skip the validator and the creation is allow

I try this for my conditional Validation :  

(issue.customfield_10054.value == "1" && (issue.components.some(it => it.name != "A"))) || (issue.customfield_10054.value == "1" && (issue.components.some(it => it.name != "B")))

But It's not ok, still return "True"
I think because we are still one or other option  .. True.

We cannot use if/else in Validator condition ( only in postfunction) right ?

So I don't know how to do this , any help are appreciate :)

2 answers

2 accepted

1 vote
Answer accepted
David Fischer
Community Champion
May 6, 2024

Hi @Yoann LEGRAND 

A simpler version of the Jira expression:

issue.customfield_10054.value != "1" || !issue.components.some(it => it.name == "A" || it.name == "B")

 which will pass if the custom field value is not "1" or if the component doesn't contain A or B

Yoann LEGRAND
Contributor
May 6, 2024

Thx David :)

0 votes
Answer accepted
Yoann LEGRAND
Contributor
May 6, 2024

OK, I've found it ! I post answer here , if some people block like me ;) 

(issue.customfield_10054.value == "1" && (issue.components.some(it => it.name == "A"))) || (issue.customfield_10054.value == "1" && (issue.components.some(it => it.name == "B"))) || issue.customfield_10054.value != "1"

But not in "Conditionnal validation" .. directly in Jira Expression !

It easy in fact ... I'm looking for too complex !

Suggest an answer

Log in or Sign up to answer