Hi,
When creating a sub-task I am trying to add users by their login id firstname_lastname to a Multi User Picker Customfield but it fails :
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'My Multi User Picker Custom Field'}
issue.setCustomFieldValue(cf, 'firstname_lastname1, firstname_lastname2, firstname_lastname3,');
What is wrong please ?
Thanks & regards,
Camille
Hi Mark and Alexey,
Thank you for your help. Infortunately it did not work for me... I decided to use a workaround with an other plugin I have : Precondition: Value Field (JSU) + Update Any Issue Field (JSU)
Hello @Camille Lecerf
Answer of @Alexey Matveev essentialy right. But UserUtil interface is deprecated and not recommended to use.
Use UserManager instead, here is script.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'My Multi User Picker Custom Field'}
List<ApplicationUser> userList = new ArrayList<>()
userList.add(userManager.getUserByKey("user1"))
userList.add(userManager.getUserByKey("user2"))
userList.add(userManager.getUserByKey("user3"))
issue.setCustomFieldValue(cf, userList);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You need to pass an array of ApplicationUser.
It would be something like this:
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'My Multi User Picker Custom Field'}
List<ApplicationUser> userList = new ArrayList<>()
userList.add(ComponentAccessor.getUserUtil().getUserByKey("user1"))
userList.add(ComponentAccessor.getUserUtil().getUserByKey("user2"))
userList.add(ComponentAccessor.getUserUtil().getUserByKey("user3"))
issue.setCustomFieldValue(cf, userList);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.