It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script no longer working after update

Getting an error with our script after upgrading Jira (see script below-error is here **)

 

import com.atlassian.jira.component.pico.ComponentManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.ProjectRoleManager

ComponentManager componentManager = ComponentManager.getInstance()
**ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager**

def String user
def project = issue.getProjectObject()

ProjectRole role1 = projectRoleManager.getProjectRole("HR")
ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(role1, project)
user = actors.getUsers().toList()?.first()?.name

if(user){
issue.setAssigneeId(user)
}

 

I changed the ComponentManager but can't see to figure out the rest.

1 answer

1 accepted

0 votes
Answer accepted

Hi @yadeniji ,

please try to replace your code with this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

final String roleName = "HR"

ProjectRoleManager projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

def projectRole = projectRoleManager.getProjectRole(roleName)
def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject).applicationUsers

if (users) {
    issue.setAssignee(users.first())
}

 

Thank you for your reply.  I replaced the code, but now we get this error when I look at the post function.

 

The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.

2020-01-14 15:09:44,961 ERROR [workflow.AbstractScriptWorkflowFunction]: *************************************************************************************
2020-01-14 15:09:44,962 ERROR [workflow.AbstractScriptWorkflowFunction]: Script function failed on issue: COSTAT-14080, actionId: 1, file: null
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.component.pico.ComponentManager.getComponentInstanceOfType() is applicable for argument types: (java.lang.Class) values: [interface com.atlassian.jira.security.roles.ProjectRoleManager]
Possible solutions: getComponentInstanceOfType(java.lang.Class), getOSGiComponentInstanceOfType(java.lang.Class)
 at Script35.run(Script35.groovy:7)
Hana_Kučerová Community Leader Jan 15, 2020

Hi @yadeniji ,

which version of Jira do you have now (i. e. after mentioned upgrade)?

We are running version 8.5.1 right now

Looks the errors stopped!

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you