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!
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. 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:
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"
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...
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