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 copy value of MultiUser picker field to Assignee field

Hello Everyone,

I want to set the first selected user in the list of Multi-User picker as the value of Assignee field. I used in built post function of JSU (JIRA Suite Utilites plugin) and the below code in custom script post function:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def uatTesters = customFieldManager.getCustomFieldObjectsByName("UAT Testers").first()
if(issue.getCustomFieldValue(uatTesters)) {
List<ApplicationUser> uatTestersVal = (List<ApplicationUser>) issue.getCustomFieldValue(uatTesters)
issue.setAssignee(uatTestersVal[0]) }

 

Both methods result in populating Assignee field with the user whose Full Name has alphabetical precedence. How can I set the assignee field with the first selected user in list.

Any help would be appreciated. Thanks in advance.

1 answer

0 votes

Hi

There is no inherent sequence to the list of users associated with a Multi-User Picker.

In fact, it is my observation that the list is always sorted alphabetically with every save operation. 

At the database level, there would be an incrementing unique id for each value instance. But with each save/update, the whole list is removed/replaced with the new list of users and the user list is always alphabetical.

So if the first user has a different significance compared to the other users, you must separate that user into a separate field: like "primary" and "others". Then you can change the assignee to the primary user field.

Hello @Peter-Dave Sheehan ,

Thank you for the reply.

When you say- "you must separate that user into a separate field: like 'primary' and 'others'", what exactly do you mean?

Could you please elaborate on this.

Thanks and Regards

Swapnil Srivastav

I don't really have details about your scenario.

But conceptually, you appear to have 2 different business uses for users that are currently stored in the multi-user picker field. 

So I am suggesting you separate that first user into its own field. 

If, for example, your user picker field is used to designate a team. And the "first user" is meant to be the team captain. Then you should have 2 custom fields:

  1. team captain - single user picker
  2. rest of the team - multi-user picker

This way, in your script, you can be certain that you can always select the team captain by looking at the correct field.

Hello @Peter-Dave Sheehan ,

That is a very creative workaround. But at the moment, we have to work with multi-user picker only.

Thank you for the reply

Regards

Swapnil Srivastav

Suggest an answer

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

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

880 views 14 20
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