Use the behaviour functionality of the script runner to show/hide fields



You can’t imagine what Atlassian JIRA allows you to track. To accommodate all potential reporting needs, large companies tend to expand the number of fields on forms. In a number of cases, fields are only relevant under particular conditions.   Making users understand the logic behind these fields and dependencies is in many cases a daunting task.  Try to explain that the effectiveness review field must be entered in case of a high impact issue with a medium to a critical severity …

Luckily the Script Runner for JIRA provides ‘Behaviours’. A behavior defines how fields behave for issues in a given project or issue context. Some examples of behaviors are:

  • Making a field mandatory depending on other data entered on the issue screen (i.e during an issue creation or an issue transition)
  • Making a field read-only dependent on user role or group
  • Doing server-side validation of field data, before the issue screen is submitted
  • Setting a field value dependent on other issue screen data

A small example what the behavior add-on provides

Configuring behaviors might seem a bit rough in the beginning but once you understand how to setup such behavior, very neat things can be done.

To implement the behavior above take following steps

  • Access the behavior menu under Administration – Addons


  • Create a new behavior


  • Add a field to the behavior
    In this case, the behavior is triggered by changes in the drop down field


  • Now define what should happen when the field is changed by a user, by adding a server side script


  • Add the script itself
    In this case the script should show a text field (condition A, condition B) depending on the selected drop down value


def dropDown = getFieldById("customfield_10500")
def conditionA = getFieldById("customfield_10501")
def conditionB = getFieldById("customfield_10502")
log.debug("dropdown value" + dropDown.getValue())
if (dropDown.getValue() == "a") {
} else {

The customfield id’s are retrieved by accessing the custom field configuration screen and look at the URL …

  • Done – have a chocolate

Further Reading

Check out the document on the Adaptavist site:

The script runner has endless possibilities to customize your JIRA to your operating environment. Want to know more, don’t hesitate to attend the ‘automate your processes with JIRA’ event on April 14.