How to enable/disable custom field on screen based on another custom field values? [Jira] [Behavior]

mohit panwar August 28, 2021

Hi Team,

I have a requirement to disable the Custom field "Group" and "User" once the value from "option" custom field is returned as "Add Group".

Below is the piece of code i am trying. And it is not working. I need to disable this at screen level. A early reply will be appreciated as need this functionality for my prod release.

def option = getFieldById("customfield_18404")
def Group = getFieldById("customfield_18405")
def User = getFieldById("customfield_18406")

String optionVal = option.getFormValue();

if(optionVal.equals("Add Group")){
Group.setReadOnly(true);
} else {
Group.setReadOnly(false);
}

if(optionVal.equals("Add Group")){
User.setReadOnly(true);
} else {
User.setReadOnly(false);
}

1 answer

0 votes
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2021

Hi  @mohit panwar May i know the field type of Option field ?

If it's dropdown :- 

def option = getFieldById("customfield_18404")

if (option.getValue() == "Add Group")
def option = getFieldById(getFieldChanged())

def option_value = option.getValue()
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2021

formField.getValue()
Gets the value that is current in the form. For certain fields, this does do some conversions.

Select fields, radio buttons, checkboxes, etc. the string value will be returned, or a List of string values.

mohit panwar August 28, 2021

@Vikrant Yadav 

Thanks. Option is the Radio Button.

 

def option = getFieldById(getFieldChanged())

def option_value = option.getValue()

What should be the value of "getFieldChanged" here ? what parameter need to be passed in this function. 

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2021

@mohit panwar  you have to apply server side script on Option field.

getFieldChanged :- Gets the ID of the field that this script is attached to.

Like mohit panwar likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2021

Code should be like this :- 

def option = getFieldById(getFieldChanged())

def Group = getFieldById("customfield_18405")

def option_value = option.getValue()

if (option_value == "Add Group") {

     Group..setReadOnly(true)

}
Like mohit panwar likes this

Suggest an answer

Log in or Sign up to answer