Forums

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

How can I create a Behaviour condition based on the value of a text field

Mick Lovell
Contributor
August 14, 2019

Hello,

 

I have a select list field that I want to hide unless another text field has a value.

I'm trying to implement the solution posted at https://community.atlassian.com/t5/Jira-Core-questions/Condition-on-a-custom-field-basis-for-triggering-behaviour/qaq-p/850186

My code for the behaviour is:

def amountToBePaidToOther = getFieldByName("Amount to be paid to Other")
def ftr = getFieldById("FTR/NPR Justification")
log.debug("Amount to be paid to Other value" + amountToBePaidToOther.getValue())

if (amountToBePaidToOther.getValue() == null) {
ftr.setHidden(true);

} else {
ftr.setHidden(false);

}

I've tried configuring the script to both fields.

When I view the customer portal, the select list field is still visible with no value in the text field.

 

Thank you.

2 answers

1 accepted

0 votes
Answer accepted
Mick Lovell
Contributor
August 15, 2019

Instead of null, I used "" and the Behaviour works.

def amountToBePaidToOther = getFieldByName("Amount to be paid to Other")
def ftr = getFieldById("FTR/NPR Justification")
log.debug("Amount to be paid to Other value" + amountToBePaidToOther.getValue())

if (amountToBePaidToOther.getValue() == "") {
ftr.setHidden(true);

} else {
ftr.setHidden(false);

}

0 votes
Roman Kersky
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, 2019

hi. Change this line:     def ftr = getFieldById("FTR/NPR Justification")

on 

def ftr = getFieldByName("FTR/NPR Justification")

Mick Lovell
Contributor
August 15, 2019

Thank you Roman.  The FTR field still does not react to the behaviour, but thank you for catching that error.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events