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:
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def uatTesters = customFieldManager.getCustomFieldObjectsByName("UAT Testers").first()
List<ApplicationUser> uatTestersVal = (List<ApplicationUser>) issue.getCustomFieldValue(uatTesters)
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.
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.
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:
This way, in your script, you can be certain that you can always select the team captain by looking at the correct field.
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...
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