It’s very easy to do in Jira Server with the help of the awesome plugin Adaptavist Scriptrunner. 

Just create a new Behaviour ( press “.” and write Behaviours).

Captura de pantalla 2018-03-18 a las 13.34.45

Associate the Behaviour to your project (and/or issuetype/s).

And the click in “Fields” to add the field you want to “observe”. For example, custom field “Jira Category“.

Captura de pantalla 2018-03-18 a las 13.28.48

We will hide/show a field called “Jira Project affected” and we will set as mandatory when “Jira Category” field matches some value (for example will be hide when the value is set to “Confluence Permission Problem“)..

Captura de pantalla 2018-03-18 a las 13.26.27

Field to hide (and set as optional and not mandatory)

Captura de pantalla 2018-03-18 a las 13.26.47

We need to place a code like this in the Behaviour.

Captura de pantalla 2018-03-18 a las 13.28.29


def browserField = getFieldByName("Jira Project affected")
def categoryField = getFieldById(getFieldChanged())
browserField.setRequired(true)

def patternAppConfluence = "Confluence Permission Problem"

def selectedOption = categoryField.getValue() as String

def matcher = selectedOption =~ patternAppConfluence
def isConfluenceApp = matcher.matches()

browserField.setHidden(isConfluenceApp)
browserField.setRequired(!isConfluenceApp)

That’s all!

By MrAddon

Posted by:.

One thought on “Show/Hide Mandatory fields in Jira dynamically with Behaviours

Leave a comment