Forums

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

how to restrict field values based on another field values selection

suren June 12, 2023

 I am looking to restrict field values based on another filed values?

Like I have single select fields called "Instance" and values Dev, Production,

  and I have one more select field called "Number" values 1, 2, 3 ,4 5, 6 ,7 ,8 9

When I select "Dev" value in Instance I need to see only 1, 3, 5 values in number filed.

If I select production I need to see all values in Number field.

 

Can this done by without plugin?

 

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee
Community Champion
June 12, 2023

Hi @suren

Unfortunately I don't believe there's a way to restrict the field values, even with an add-on. (Behaviours has the "Manage field options" action available in DC/Server, but not Cloud.)

I think the best you could do is add a Description to the Fields telling what values are valid for the Instance type, and then create a Custom Validator for your Workflow that doesn't allow users to submit if it doesn't match your requirements.

This will require purchase of an add-on (see link below):

The Custom Validator (aka Build-your-own (scripted) Validator) would need to be written using Jira Expressions and would look something like this (assuming 'Instance' field is customfield_12345 and 'Number' field is is customfield_23456):

(issue.customfield_12345.value == "Dev" && ['1','3','5'].includes(issue.customfield_23456.value)) ||
(issue.customfield_12345.value == "Prod" && ['2','4','6'].includes(issue.customfield_23456.value))

So for the Number field (on my test server I just used my generic "Single Select Field", you could edit the Field Description to say something like:

 Screenshot 2023-06-12 at 11.04.21 PM.png

The add-ons allow you to put up an error-message if the expression evaluates as false, so you could then put a more explicit message:

Screenshot 2023-06-12 at 11.24.01 PM.png

You can add even more explicit instructions via the read-only "Message Custom Field", which would look something like this:

Screenshot 2023-06-12 at 11.24.08 PM.png

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events