Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JMWE Validator: How to make the child level of Cascading field required?

Tyler Stephens March 30, 2022

HI!

 

I have a use case to make a child level of a cascading field required.

I am trying to do this through a validator...

Cascading Field has two options:

  • Example 1 (with no children)
  • Example 2
    • Child 1
    • Child 2
    • Child 3

How can I build a validator that will only trigger if Example 2 is picked without a child value selected?

 

Thanks!

2 answers

1 accepted

2 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 31, 2022

Hi @Tyler Stephens 

using JMWE, you can create a Build-your-own (scripted) Validator, with code like this:

!!issue.customfield_12345 && !!issue.customfield_12345.child

where you'll replace customfield_12345 with the custom field ID of your cascading select field (which you can find on the "Issue Fields" help tab below the Jira expression editor).

Tyler Stephens March 31, 2022

Hi @David Fischer 

 

One of the Cascading options doesn't have a child option. The code mentioned will cause it to fail when this option is selected. 

 

If user selects Normal, the JMWE should pass.

 

However, if Hotfix is selected without selecting a child option, it should fail. 

 

Cascading field:

2022-03-31_12-26-31.png

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 31, 2022

Unfortunately, you cannot check possible values in a Jira Expression (this is a Jira limitation). Therefore, you'll need to hardcode the value that doesn't require a child option:

!!issue.customfield_12345 && (issue.customfield_12345.value == "Normal" || !!issue.customfield_12345.child) 
Like Joseph HANI likes this
Tyler Stephens March 31, 2022

@David Fischer Thank you!

0 votes
Tyler Stephens March 31, 2022

Hi@David Fischer ,

You helped me previously with some JMWE, do you have any advice on this?

Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events