Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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


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 ?


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
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

116 views 1 9
Read article

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