Post script function - multiple user picker custom field update

Can't update multiple user picker custom field. 

Workflow transition's post function script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager()
def Approvers = customFieldManager.getCustomFieldObjectByName("MultipleUserPicker")
List<applicationuser> newApprovers = []; 
ApplicationUser user = userManager.getUserByKey("user1"); 
user = userManager.getUserByKey("user2"); 
issue.setCustomFieldValue(Approvers, newApprovers);

This code gives no mistake in text editor, but when I performing transition it alerts:
It seems that you have tried to perform an illegal workflow operation.If you think this message is wrong, please contact your JIRA administrators.

I can't see logs. Does anybody know what is wrong? When I comment this line "issue.setCustomFieldValue(Approvers, newApprovers)" alert disappears.

Here on this page is example only for (single select) user picker. 
Thank You!

2 answers

1 accepted

1 vote
Answer accepted

You should use IssueService, which will do the reindexing for you. You should be able to replace your script with the one below:

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueService = ComponentAccessor.getComponent(IssueService)
def approvers = customFieldManager.getCustomFieldObjectByName("MultipleUserPicker")

def issue = issue as Issue

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def issueInputParameters = issueService.newIssueInputParameters()

// Adding the user names here
issueInputParameters.addCustomFieldValue(, "user1", "user2")

def updateValidationResult = issueService.validateUpdate(user,, issueInputParameters)

if (updateValidationResult.isValid()) {
    issueService.update(user, updateValidationResult)

I changed names of CustomField and users but it is not working.
This script generates no error, but field is empty. =((

I think I know what happened, user must have a permission to edit? I'll check it...

Is it possible to select another user, not current logged in? 
"Edit issue" is deprecated in our project, we are changing fields in transitions. Each field in its own transition (very strict).

Yes if the logged in user does not have issue edit permissions it can't be done. You should run it as a user with the correct permissions. You can get a user like so:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager

def userManager = ComponentAccessor.getComponent(UserManager)

def user = userManager.getUserByKey("userkey")

Hi Adam,

I'm trying to do the same, but what i have is an array / list of users (= MemberUsernames) of which i do not know how many they will be.

Do you have a suggestion on how i could do that?

issueInputParameters.addCustomFieldValue(, MemberUsernames)

def updateValidationResult = issueService.validateUpdate(currentReporterFull,, issueInputParameters)

if (updateValidationResult.isValid()) {
issueService.update(currentReporterFull, updateValidationResult)

Thanks and best regards


I changed names of CustomField and users but it is not working.
This script generates no error, but field is empty.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


119 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you