Forums

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

Chek if list is not empty to setup required field (in behavior)

Boris Demain July 29, 2019

Hi, 

in behavior, I need to set required field but some times I have values in my list field but other time I have empty list. Depending of project context.

Is it possible to script something to check if my list field is not empty ?

Thanks

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
PD Sheehan
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 1, 2019

Yeah, get the list of options from OptionsManger

Something like this:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def cf = customFieldManager.getCustomFieldObjectByName("you list field")
def formField = getFieldById(cf.hiddenFieldId)
def config= cf.getRelevantConfig(issueContext)
def optionList = optionsManager.getOptions(config)

formField.setRequired(optionList.size() > 0)
TAGS
AUG Leaders

Atlassian Community Events