Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to set field hidden

Swarna Radha
Contributor
August 15, 2018

Hi,

I want to set a field hidden based on another custom field using behaviour. But the hidden field is not showing up when i select Yes. Please see code:


//defining variable to get custom fields

def testscript_field = getFieldByName ("Tests Scripts / Test Results successful (Yes/No)")
def Signoff_path_field = getFieldByName ("Specify Test Scripts/UAT Signoff path")

//Retrieving the current field value as a String
def script_value = testscript_field.getValue() as String
def isOtherSelected = script_value

if(testscript_field == "Yes")
{
Signoff_path_field.setHidden(false)

}

else
{
Signoff_path_field.setHidden(true)
//Signoff_path_field.setRequired(true)
}

Thanks

Swarna

3 answers

0 votes
Alexey Matveev
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.
August 15, 2018

Hello,

Could you add logging to your code and have a look in the atlassian-jira.log file for your logging output?

//defining variable to get custom fields

def testscript_field = getFieldByName ("Tests Scripts / Test Results successful (Yes/No)")
def Signoff_path_field = getFieldByName ("Specify Test Scripts/UAT Signoff path")

//Retrieving the current field value as a String
def script_value = testscript_field.getValue() as String
def isOtherSelected = script_value

log.error("isOtherSelected:  " +isOtherSelected )

log.error("Signoff_path_field: " + Signoff_path_field)

if(isOtherSelected == "Yes")
{
Signoff_path_field.setHidden(false)

}

else
{
Signoff_path_field.setHidden(true)
//Signoff_path_field.setRequired(true)
}
0 votes
Tushar
Contributor
August 15, 2018

HI,

Try the below code in behaviour, if the finCF field is select list customfield:

 

def finCF= getFieldByName ("Tests Scripts / Test Results successful (Yes/No)")
def appCF = getFieldByName ("Specify Test Scripts/UAT Signoff path")

appCf.setHidden(true)
appCf.setRequired(false)

if (finCf.getValue() == "Yes")
{
appCf.setHidden(false)
appCf.setRequired(true)
}
else //Change Type is set to Normal
{
appCf.setRequired(false)
appCf.setHidden(true)
}

 

 

Hope this will help you.

 

~Tushar

Swarna Radha
Contributor
August 15, 2018

@Tushar

I have tried your code, but it is not working.

Swarna

0 votes
Yogesh Mude
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.
August 15, 2018

Hi @Swarna Radha

In the If-else loop just you have been used testscript_field, but you are not fetching values.

Swarna Radha
Contributor
August 15, 2018

Hi Yogesh,

I have updated the script but still the another field is not showing up


//defining variable to get custom fields

def testscript_field = getFieldByName ("Tests Scripts / Test Results successful (Yes/No)")
def Signoff_path_field = getFieldByName ("Specify Test Scripts/UAT Signoff path")

//Retrieving the current field value as a String
def script_value = testscript_field.getValue() as String
def isOtherSelected = script_value

if(isOtherSelected == "Yes")
{
Signoff_path_field.setHidden(false)

}

else
{
Signoff_path_field.setHidden(true)
//Signoff_path_field.setRequired(true)
}

Suggest an answer

Log in or Sign up to answer