Hide custom fields based on a custom field value, and also hide based on status/transitions

We are trying to hide custom fields based on one of our custom fields value (team), and also hide custom fields based on the workflow status and transition.

We are using Adaptavist scriptrunner and can do this in two separate behaviours:

1. Hide certain custom fields based on a custom fields value (so each team only see their own custom fields -  some fields are shared)

2. Hide certain custom fields except when they are in certain workflow statuses or transitions.

If we did one of the above behaviours then the behaviour works correctly. However, if we add both behaviours then only Behaviour 1 works. The custom fields are hidden based on a custom fields value, but the custom fields still appear in all statuses/transitions.

Is there anyway to have both of these behaviours working together, possibly using groovy scripting in a single behaviour?

1 answer

0 vote
Joshua Yamdogo Community Champion Nov 14, 2017

I think what you are trying to accomplish can be done with behaviours by adding a condition to see which screen the user is on. Here is some sample code to get you started:

You can use the following to apply the behavior to a specific screen to validate input.

if (getFieldScreen().name == "Some Screen Name") { // check user has a certain screen up    def valueToCheck = getFieldByName("testField") // get the field    // get value and do stuff   }

You can use behaviors to modify the visible/required fields on a screen. You can use a scripted transition to limit the behaviour to a particular workflow step, so that it's only applied on the relevant transition screen.

if (getActionName() == "Transfer Ownership") {
    def fieldToHide = getFieldByName("Some custom field I wish to hide")
    def fieldToRequire = getFieldByName("Some custom field I wish to require")
    fieldToHide.setHidden(true)
    fieldToRequire.setRequired(true)
}

See if you can get something working using the code above. 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,313 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot