Hiding custom field when value in a previously filled is a particular one

Gagan Inder Sekhon
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 11, 2018

Hi so i have been trying to hide a field when my previous field has a particular selection out of a list of three namely None, sick, casual

I want the reason for the leave field to be hidden in case type of leave is  sick or casual
in case it is None i want it to be accesible

Ive been trying behaviour but had no luck maybe im going wrong somewhere if someone could guide me thank you

-----------------------------

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
def approver = getFieldByName("reason for the leave")
def tOL = getFieldById(getFieldChanged())

def selectedOption = tOL.getValue() as String


if (selectedOption == "None") {
approver.setHidden(true)
} else {
approver.setHidden(false)
}

 

1 answer

0 votes
Mark Markov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2018

Hello @Gagan Inder Sekhon

None option is null, so script should be like this

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours
def approver = getFieldByName("reason for the leave")
def tOL = getFieldById(getFieldChanged())

def selectedOption = tOL.getValue() as String


if (selectedOption == null) {
approver.setHidden(true)
} else {
approver.setHidden(false)
}

 

Suggest an answer

Log in or Sign up to answer