Can anyone help me move away from jira.componentManager, and replace with alternative in the appropriate places, particularly lines 1 and 20 (and any others which you deem necessary)
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
String projectField = "Architect"
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def field = customFieldManager.getCustomFieldObjectByName(projectField)
def projectAffected = customFieldManager.getCustomFieldObjectByName("Affected Project")
def projectAffectedValue = (issue.getCustomFieldValue(projectAffected).toString()).replaceAll("<[^>]+>| |\n", "")
ComponentManager componentManager = ComponentManager.getInstance()
ProjectManager projectManager = ComponentAccessor.getProjectManager()
ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager
// name of role here
ProjectRole projectRole = projectRoleManager.getProjectRole(projectField)
ProjectRoleActors actors = null
def valueField = issue.getCustomFieldValue(field)
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
String projectSetName = "empty"
String fred = "empty"
if(projectAffectedValue.toString() in null) {}
else {
projectManager.getProjectObjects().each {
Project project ->
projectSetName = project.getName()
if (projectSetName.equalsIgnoreCase(projectAffectedValue.toString())) {
fred = "in"
actors = projectRoleManager.getProjectRoleActors(projectRole, project)
}
}
if (actors in null) { }
else {
fred = "else"
field.updateValue(null, issue, new ModifiedValue(actors.getUsers().toList()?.first(),actors.getUsers().toList()?.first()), changeHolder);
}
}
I am using datacenter 8.4.2 and scriptrunner 6.13.0
Hi @Nicole Downes,
below code may help you
1. import statement --> import com.atlassian.jira.bc.projectroles.ProjectRoleService
2. Getting Project Role Service/Manager
def projectRoleService =ComponentAccessor.getComponent(ProjectRoleService);
def projectRoleManager =ComponentAccessor.getComponent(ProjectRoleManager);
def projectManager =ComponentAccessor.getComponent(ProjectManager);
BR,
Leo
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.