Hello, I'm new to Scriptrunner, can someone help me solve it.
I wanted to set up Listener so that a performer is assigned for certain projects and in the UserPicker(multiple users) field add multiple users. These users may be inactive.
Part of the code for assigning the performer was found and works fine,
but there were problems with adding users to the UserPicker(multiple users) field.
How to do it correctly?
Thanks in advance for any help!
import java.lang.String
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.component.ComponentAccessor
import java.util.ArrayList
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def multiUserPicker = customFieldManager.getCustomFieldObject("customfield_10501") // -UserPicker(multiple users)
ArrayList<ApplicationUser> usersList = new ArrayList<ApplicationUser>()
//SCRUM - Jira Software project
//HRDesk - JSD project
//Users SCRUM
final String assigneeSCRUM = "UserScrum"
final List<String> usersSCRUM = ["User1", "User2", "User3"]
//Users HRDesk
final String assigneeDESK = "UserDesk"
final List<String> usersDESK = ["User3", "User4"]
if (issue.projectObject.key == 'SCRUM') {
def user = ComponentAccessor.userManager.getUserByName(assigneeSCRUM)
issue.setAssignee(user)
usersList.addAll(usersSCRUM)
issue.setCustomFieldValue(multiUserPicker, usersList)
}
if (issue.projectObject.key == 'HRDesk') {
def user = ComponentAccessor.userManager.getUserByName(assigneeDESK)
issue.setAssignee(user)
usersList.addAll(usersDESK)
issue.setCustomFieldValue(multiUserPicker, usersList)
}