No signature of method getProjectRole() is applicable for argument types Long or String

I am trying to return a Project Role as part of a script that is ultimately going to provide the Project Role Actors for a given Project Role in a specified project. My script keeps getting:

groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.security.roles.ProjectRoleManager.getProjectRole() is applicable for argument types: (java.lang.String) values: [Operations Manager]

OR

groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.security.roles.ProjectRoleManager.getProjectRole() is applicable for argument types: (java.lang.Integer) values: [10200]

depending on whether I pass the variable roleId or roleName to he function. 

The script currently looks like :

import com.atlassian.jira.component.ComponentAccessor
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.issue.customfields.manager.OptionsManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def projectManager = ComponentAccessor.getProjectManager()
//def projectRoleManager = ProjectRoleManager.getProjectRoleManager()
//def componentManager = ComponentAccessor.getInstance()
//def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class)
//def customFieldManager = componentManager.getCustomFieldManager()

def cf = customFieldManager.getCustomFieldObjectByName("Affected Project")
def roleProject = issue.getCustomFieldValue(cf)
// added this line
def project = issue.getProjectObject()
//
long roleId = 10200
def roleName = "Operations Manager"
//def project = projectManager.getProjectObjByName(String roleProject)
def projectRole = ProjectRoleManager.getProjectRole(roleId)
// changed roleProject to project
def projectRoleActors = ProjectRoleManager.getProjectRoleActors(projectRole, project)
return roleProject

Can you please explain what I am doing wrong?

1 answer

Maybe it's not static, so you need to instantiate a ProjectRoleManager.  I use this:

ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager

ProjectRole devsRole = projectRoleManager.getProjectRole("Developers")

There's probably a cleaner way to do it, I just pulled that off the net somewhere.

Use ComponentAccessor.getComponent(...) but otherwise yes that's the problem. You can tell by:

No signature of method: static com.atlassian.jira.security.roles.ProjectRoleManager.getProjectRole() 

 

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,861 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot