I am using the following script to add values to users picker filed(multi user) and is added as a script post function:
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUser
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueService = ComponentAccessor.getComponent(IssueService)
def approvers = customFieldManager.getCustomFieldObjectByName("Ticket Viewers")
def customFieldValue = issue.getCustomFieldValue(approvers);
//String selectedviewer = issue.getCustomFieldValue(approvers)
def issue = issue as Issue
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueInputParameters = issueService.newIssueInputParameters()
// Adding the user names here
issueInputParameters.addCustomFieldValue(approvers.id, "username1", "username2")
def updateValidationResult = issueService.validateUpdate(user, issue.id, issueInputParameters)
if (updateValidationResult.isValid()) {
issueService.update(user, updateValidationResult)
}
However, if there is already a value in the user picker field it gets deleted. Only username1 an username2 are left as values in the field.
Can somebody help me to just append two usernames to alreday populated filed?
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.