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.
Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.
Learn moreOnline 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.