Change Field's Requiredness and Visibility - ITSM

Overview

Set up a behaviour that changes the visibility of a field depending on the priority of an issue.

  • Navigate to Add-ons > Behaviours, using the Administration Cog in the top right corner.
  • Under Add Behaviour, enter a Name and Description.
  • Click Add.
  • Click on the Fields option for the newly created behaviour. Add the behaviour to the Priority field by choosing it from the drop-down list and clicking Add.
  • Select Add Server-Side Script.
  • The inline script should appear, paste this code snippet into it.

Example

Detailed use case example: Adding Behaviours to The Customer Portal

Requirements

Jira Jira (7.3 - 7.13)

import com.atlassian.jira.issue.priority.Priority
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def priorityField = getFieldById(fieldChanged)
def customField = getFieldByName("Number Field")
def priorityValue = priorityField.value as Priority

priorityValue.name == "Highest" ?
    customField.setRequired(true).setHidden(false) :
    customField.setRequired(false).setHidden(true)

Discovered an issue? Report it here

Suggested for you

Appears in these Collections