Adding automatically request participants from a custom field and defined users Edited


we user JIRA Service Desk for our onboarding process.
In the customer portal we have a custom field "Contact person" (single user picker).

This custom field can automatically added to the request participants via post-function (copy field to request participants).
Now we want to add specific users in addition to "Contact Person"-custom field.
For this we used the following script: How to Automatically Add Request Participants when Creating an Issue

Both works individually, but together, only the last executed job (copy field or script) of the transition to request participants is added.

The last script that was tested is the following:


package UpdateIssue

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue

def requestParticipantsField = customFieldManager.getCustomFieldObjectByName("request participants")

def users = (customFieldManager.getCustomFieldObjecByName("Contactperson").getValue(issue).toString() + ", username1, username2, username3, username4, username5")

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();

issue.setCustomFieldValue(requestParticipantsField, users)

This added the contact person, but not the specific users.
I have searched for a long time and tested several scripts, but its never set both "variables".
Can anybody help me further? Does anyone have perhaps another idea how I get this configured?

Thank you for your answers and help!


2 answers

1 accepted

0 votes
Accepted answer

Hi @Thanos Batagiannis [Adaptavist],

no problem.

Yes, you got it right. But that is not all ;)
The action should be executed when the issue gets created.

I would like to add the following users to the request participants:

  • custom field "Contact person" (single user picker)
  • specific users (e.g. Bob, Bill and Will)

"Contact Person" is different from issue to issue, the specific users are always the same.

Your script from your first answer works fine, only the "Contact Person" from an already exiting process is used, which is not practical because there are different users from issue to issue.

My idea was to get the current issue key to get the "Contact Person" from the current issue. But unfortunately no success.

regards, Alex


Hi Alex, 

So you will need a custom post function that will be the first one in the create transition. And the script will look similar to 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser

def issue = issue as MutableIssue

// given some user keys, collect the application users
def usersToAdd = ["paolo", "niki", "omar"].collect { ComponentAccessor.userManager.getUserByKey(it) }

// get the user in the user picker field
def contactPersonCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("UserPicker")
def user = issue.getCustomFieldValue(contactPersonCF) as ApplicationUser

if (user)

def requestParticipantsCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Request participants")

// set the request participants value
issue.setCustomFieldValue(requestParticipantsCF, usersToAdd)

Please let me know if this does the trick

Kind regards,


Hi @Thanos Batagiannis [Adaptavist],

sorry for the late reply.

But now i can say... it works! :)
That is the trick, awesome!

I only changed the "getCustomFieldObjectByName" to "getCustomFieldObject" and I had given the custom field ID.

Thank you very much for your help and your time! :)

kind regards,


P.S.: i can't mark your answer as solution.. :-/

Hi Alexander

Try something similar to the script below. I added some comments in order to make it more clear, please ping me if you have any questions

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

// a collection of the users that will be the request participants
def users = []

// a jira issue that we are getting the user in a UserPicker custom field
def jiraIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("TAT-1")

// the service desk issue to set the request participants
def serviceDeskIssue = issue as MutableIssue

def requestParticipantsField = customFieldManager.getCustomFieldObjectByName("Request participants")
def userPicker = customFieldManager.getCustomFieldObjectByName("UserPicker")

// user A comes from the UserPicker field from issue with key TAT-1
def userA = jiraIssue.getCustomFieldValue(userPicker)

// we get userB from the user key
def userB = ComponentAccessor.getUserManager().getUserByKey("paolo")

// add all users to the collection

// set the Request participants for the service desk isse in transition,
// make sure it comes before the Update change history for an issue and store the issue in the database step
serviceDeskIssue.setCustomFieldValue(requestParticipantsField, users)

regards, Thanos

Hi @Thanos Batagiannis [Adaptavist],

many thanks for your response! :)

The scrips looks good and works fine, but i have one more questions.

I would like to add the value of the userpicker, which was defined from the customer in the Service Desk portal and not by particular already existing issue ("TAT-1"). 
How is that possible? I tried the following, but it doesn't work.


def userA = customFieldManager.getCustomFieldObjectByName("UserPicker").getValue(issue)

Do you have an idea? Or did I misinterpreted your code regarding TAT-1?

Thanks for your answer!

regards, Alex

Edit: sorry, i forgot to mention..

Hey @Thanos Batagiannis [Adaptavist],

to find the current issue key and then read out the user from "Contract Person"-custom field, I have tried the following:


def currentIssue = issue.getKey()

def jiraIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("currentIssue")


But unfortunately also without success.
"Contact person" was defined from the customer in the Service Desk portal and is always different.

Is there a way to solve the case?

Thank you very much!


regards, Alex

Hi Alex, 

Sorry I didn't follow earlier, I was not getting any notifications. 

So If I understand well you want to get the value from a UserPicker field (Contract Person) and add it to the request participants ? 

And if that is the case then, under which circumstances you want this to happen ? (When an issue gets created or transitioned ? or when the Contract Person field gets updated ) ?

regards, Thanos 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

440 views 8 26
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