It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Make a filed Hide depending on another field using JIRA

I have 3 custom fields namely: Fruit[Apple, Mango], Apple, Mango

In my view screen, I would like to show the fields based on the Fruit user selected.

Ex: if a user selects Apple -> only Apply field should be visible and hide the Mango field and vice-versa. 

How can I achieve this?

 

I tried using the "Behaviour" plugin, but it doesn't work on the View screen.

3 answers

Hi Navya,

 

This can be achievable using "Behaviour" app which comes with script runner.

 

~Tushar

@Tushar.Kamble 

I tried that one only. it works only on create/edit screen. 

I have default values in my fields like Apple[Yes], Mango[Yes]. Fruit[Apple]

I added the below script on Fruit field

def objectType = getFieldByName("Fruit").getValue();

def apple = getFieldByName("Apple");
def mango = getFieldByName("Mango");

if (objectType == "Apple") {
mango.setHidden(true)
}

 

During issue creation time, my fields are changing according to the Fruit value. But if I open the issue, it shows all the fields :

Fruit: Apple

Apple: Yes

Mango: Yes

Hi Navya K,

Behaviours don't work on the view screen. They only function on the Create/Edit screens and the other screens mentioned here. On the view screen, any field with a behaviour on it will simply open an Edit window when clicked, as explained in the documentation. 

You can do this via "Behaviours" in ScriptRunner. You just have to add this script on the Fruit custom field.

def fruit =getFieldByName("Fruit")
def fruitVal = fruit.getFormValue() as List
def mango = getFieldByName("Mango")
def apple = getFieldByName("Apple")
apple.setHidden(true)
mango.setHidden(true)
if(fruitVal.get(0)=="Apple"){
apple.setHidden(false)
}
else if(fruitVal.get(0)=="Mango"){
mango.setHidden(false)
}
else{
log.error"---Value of fruit"+fruitVal
}

 

@Anzar Khan 

Is there any way we can hide it on view screen?

Like Anzar Khan likes this

Hi Navya,

I don't think this will be possible on the view screen.

Thanks and regards,

Anzar

Hello Navya!

Why don't you just have a multi select field, like checkboxes or something, named "Fruit" and provide "Apple" and "Mango" as the alternatives. Only the options chosen will be displayed in the view screen anyway.

I probably don't understand what you're trying to achieve, like what are the fields called "Apple" and "Mango" contain?

Feel free to explain it to me and I'll do my best to help! 

I'm trying to compare my scenario with this example, let me know if you didn't understand it.

We have 1 custom field called "Object type" which will have multiple options like Fruit, Veg, Animals. And also we have created the one web panel which should contain fields depending on the Object type. Refer :

sample.PNG

Ex: If the user selects "Fruit", the web panel should show only fruit-related custom fields. If the Object type is "Veg", panel should show only Vegetable related fields and so on. 

Like Anzar Khan likes this

Ahh I see. Maybe you can define the issue type based on the fruit alternatives instead? Like create 2 custom issue types "Apple" and "Mango", that would allow you to connect different screens containing different fields based on the selection.

If that's not an option you can also use a post function to populate the relevant fields with a default value which should make them visible on your view screen.

For example if you have 2 fields called "Colour" and "Taste" that should only be shown in your other tab if "Apple" is chosen in you multi field, the post function could give those 2 fields default values like "Colour: choose apple colour" and "Taste: choose apple taste". 

If those suggestions don't fit, please give me an example case of how the whole process looks like from your end, and I'll give it another try :) 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

274 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you