Forums

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

Behavior Multiple Custom Fields Error issue

Tehila Levin
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!
December 27, 2022

Hi all I am trying to set an error if certain values are selected in a multi select field AND a specific value is selected for another custom field. 
I have this working in a behavior mapped to the first custom field.  However, when the value of the second field is updated the error still appears. I cannot capture the field changed for the second field alongside the first. 

Any suggestions for how I can capture both values? 

heres an example of what i'm trying to do 

// get field1 - field selected in behavior 
def
fieldChanged = getFieldById(getFieldChanged())

def selectedOption = fieldChanged.value

// get field1 values into a list

def chosenValuesList = []

if (selectedOption in String) {

chosenValuesList.add(selectedOption)

} else if (selectedOption in ArrayList) {

chosenValuesList.addAll(selectedOption)

}
def field2 = getFieldByName("field2")
def field2Value = field2.getValue() as Integer


if (selectedOption && field2Value == 1 && field2Value < chosenValuesList.size()){

selectedOption.setError(lessError)

}

else{

selectedOption.clearError()

}

1 answer

0 votes
Vamsi Kandala
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.
December 27, 2022

Hi @Tehila Levin

Welcome to the community!

I maybe wrong but looks like you are checking the hardcoded value of field2 in the last 'if' condition where you are comparing 'field2Value == 1'.

So, regardless of what the actual value of 'field2' selected, the 'if' statement is always checking for '1'.

Hope this helps.

Thanks,
Vamsi

Tehila Levin
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!
January 2, 2023

Thanks Vamsi! I am comparing it to the number of multi select fields selected and it would need to be 1 to invalidate. I was able to get it to work with 2 behaviors. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events