Is it possible to copy a text field value into a user field? Using Script Runner or any other way

We have a need for a cascading group/user field in our workflow, however I have not found a add on that does this. By cascading group user field I mean:

Be able to select a JIRA group that then shows a user field that is filtered for only the users in that group. A drop down choice of users instead of a the intuitive type would be the best. Other requirement would be to be able to filter the group field for only certain groups.


Since I haven't found such an add on, my work around I've been playing with is to use a normal cascading choice field that has the values of the groups and names of users in those groups in the field. (Those only about 10 groups needed so this would be pretty easy to manage)

Then with a script runner custom script I am pulling the values out of the first cascading field value (groups) and the second part of the cascading field value (users) and setting those to 2 seperate a text fields.

From there I'd like to be able to set the assignee field with that "user" text fields value. I was wondering if anyone has done something like this. Note the "user" text field is filled in with the Display Name.

1 answer

This widget could not be displayed.

It's not that straightforward to get the user object from the displayname, and apart from anything else they are not unique. Probably the best you can do is iterate all users and find the one with the matching display name.

I tried to do that using this script. I didn't think the getDisplayableNameSafely was the right thing to use but I didn't find anything else that seemed like it would let me query by the display name(I was testing by trying to set a custom user field before I tried to set the assignee)


import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.fields.CustomField

import com.atlassian.jira.issue.ModifiedValue

import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

import com.atlassian.jira.issue.util.IssueChangeHolder

import com.atlassian.crowd.embedded.api.User



def sourceFieldName = "customfield_10253"

def targetFieldName = "customfield_10256"


ComponentManager componentManager = ComponentManager.getInstance()

CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

CustomField customFieldSrc = customFieldManager.getCustomFieldObject(sourceFieldName)

CustomField customFieldTarget = customFieldManager.getCustomFieldObject(targetFieldName)

String sourceFieldVal = issue.getCustomFieldValue(customFieldSrc).toString()

User[] users = componentManager.getUserUtil().getUsers().each().getDisplayableNameSafely(sourceFieldVal)


User test = users[0].getEmail()


IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();

customFieldTarget.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customFieldTarget), test), changeHolder)


Any help on where I went wrong would be amazing!

Hello @Kirsten Cutler did you ever got the solution . I am trying to do similar for watchers as watchers are not working through CSV. I trying using script runner.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

106 views 2 0
Join discussion

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