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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Get custom field size for a multi select User

Hi,

 

I am doing a validation to check that only 2 users can be added in the multi users pickers.

Iam getting error on the last line. Please advice.

import com.atlassian.jira.component.ComponentAccessor
//ComponentAccessor.attachmentManager.getAttachments(issue).size() >= 1

ComponentAccessor.customFieldManager.getCustomFieldObjects(issue)?.findByName("Multi user picker").size() >= 1

 

Thanks,

Swarna

1 answer

0 votes

Your code is getting a list of custom fields with the name "multi user picker" and looking at the size of that list.

What you really want to do is get the current value of the field for the current issue try something like

final String customFieldName = "My Custom Field"

def customFieldManager = ComponentAccessor.customFieldManager
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"

def customFieldVal = issue.getCustomFieldValue(customField)

def numberOfOptions = customFieldVal.size()

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Opsgenie

Investigate deployment-related incidents with Bamboo and Opsgenie together

Back in April of last year one of the major product announcements from Opsgenie was the launch of the Incident investigation view which created a deep connection between Bitbucket and Opsgenie, empow...

149 views 1 4
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