Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,782
Community Members
 
Community Events
165
Community Groups

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

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

1 vote
Answer accepted

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)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

223 views 0 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you