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 votes

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")

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

917 views 3 9
Read article

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