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.
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
import com.atlassian.jira.security.groups.GroupManager
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @[deleted] 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.