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

how to get the first value of multi user picker by script runner? Edited

I have a multi-user picker field, and would you let me know how I can get the first user in this multi-user picker field by script runner? Then, I would set the value to assignee field automatically. Thanks!

2 answers

1 accepted

0 votes
Answer accepted

A simple "get data from custom field" call will get a collection of users from a multi-user field, which you can then iterate over to get individual entries.

However, that collection is not sorted, so there's not going to be a clear definition of "first".  What is your definition of "first" here?

Hi Nic, thanks for your replying. Suppose the collection of users is a list, say listA, so "first" means the first user which is input into this field, such as listA[0]. And would you show the code how to get the value of the multi-user field, and how to get the first item of the collection? Thanks for your help. I'm new to ScriptRunner. 

Jira doesn't record that, it can't because of the nature of the field.

Imagine this sequence:

  • Fire up a browser and go create an issue with a multi-user picker.  
  • Put in Charlie 
  • Put in Bob
  • Put in Alice 
  • Remove Charlie from the list
  • Click create

The important thing here is that the browser is not sending any data about the field to Jira until the create button is hit.  At that point, the field contains "Alice and Bob", there's no data about the order they were chosen.

So, as the field has no data about the order people were added to it, you can't extract the"first" user by your definition.

You'll need to think of a different rule for who is "first"

Got it. Thanks, Nic.

wrong item

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

106 views 0 2
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