import com.atlassian.jira.security.roles.ProjectRoleActor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRole
import com.onresolve.scriptrunner.parameters.annotation.ProjectRolePicker
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.scriptrunner.parameters.annotation.CustomFieldPicker
import com.atlassian.jira.project.Project
import com.onresolve.scriptrunner.parameters.annotation.ProjectPicker
@ProjectPicker(
label = 'Project', description = 'Pick a project', placeholder = 'Pick a project', includeArchived = false
)
Project project
@CustomFieldPicker(label = 'Custom Field', description = 'Pick a custom field', placeholder='Select custom field')
CustomField customField
@ProjectRolePicker(label = 'Project role', description = 'Project role picker')
ProjectRole projectRole
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager.class)
ProjectManager projectManager = ComponentAccessor.getProjectManager()
ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole, project)
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
/*
Get all users in the project role under the project,
and then fill these users into the custom field
*/
// but I don't know how to write the next code
projectRoleActors.each { roleActor ->
//...
}
def userList = []
issue.setCustomFieldValue(customField, userList)
You can do this, yes, but why? Of what possible use is a list of roles of users in a project on an issue? It won't tell you what they can do in the project and it can and will change.
I can't see any use for this, so I don't think it's worth going to look at the code you might need.
What problem are you trying to solve with this? We can probably solve it a lot easier than kluding role records on to issues.
Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!
Register today
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.