Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

No signature of method: static com.atlassian.jira.project.ProjectManager.getProjectByCurrentKeyIgnor

Hi,

 

I need a bit of help on a behavior.

 

What i want to do: to create users, i need to set a certain set of groups to the user. I have some CFs :

- Available groups (Group Picker (multiple groups), ID 13110)

- New user - User type (drop-down)

New user - Main project (Project Picker (single project), ID 13143)

 

i have added the behavior to show/hide the "New user - Main project" field when non internal user type is selected, now i want to retrieve the group that is set on the "Service Desk Customer - Portal Access" project role of the project selected on the "New user - Main project" dropdown. 

 

I have the following code in the behavior script area:

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

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

def ProjectSelectedField = getFieldById(getFieldChanged())
def selectedOption = ProjectSelectedField.getValue().toString().split(": ")[1] as String
Project selectedProjectObj = ProjectManager.getProjectByCurrentKeyIgnoreCase(selectedOption)

def groupsField = getFieldByName("Available groups")

// name of role here
ProjectRole custRole = projectRoleManager.getProjectRole("Service Desk Customer - Portal Access")

ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(custRole, selectedProjectObj)
log.info "$selectedProjectObj.key, $selectedProjectObj.name, $selectedProjectObj.ProjectLead, ${actors.getUsers()*.name}\n";

 

When i select the value in the GUI, i have the following error in the log:

 

2018-06-27 18:52:56,722 http-nio-8080-exec-79502 ERROR g.moscalu 1132x30991261x2 10s3ksm <IP> /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] *************************************************************************************
2018-06-27 18:52:56,724 http-nio-8080-exec-79502 ERROR g.moscalu 1132x30991261x2 10s3ksm <IP> /rest/scriptrunner/behaviours/latest/runvalidator.json [c.o.jira.behaviours.BehaviourManagerImpl] Script function failed on issue: (create issue) project/issuetype: RJADM/RJADM - Access, user: g.moscalu, fieldId: customfield_13143, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.project.ProjectManager.getProjectByCurrentKeyIgnoreCase() is applicable for argument types: (java.lang.String) values: [TMONE]
at Script1.run(Script1.groovy:15)

 

Can I get some help to fix this?

 

I got the same error with getProjectByCurrentKey,  getProjectByCurrentKeyIgnoreCase,  getProjectObjByKeyIgnoreCase  and i'm out of ideas - i am probably missing something...

 

I assume that by retrieving the group object from the role, i could add it to the "Available groups" collection quite easily, but i'm not there yet...

 

Running SR 5.4.12, on JIRA 7.3.6 & SDesk 3.5.0

3 answers

1 accepted

0 votes
Answer accepted
miikhy Community Leader Jun 27, 2018

Hi Gabriel,

The static part of the error might be the reason here. Have you tried getting an instance of project manager instead of accessing it in a static way?

ProjectManager pm = ComponentAccessor.getProjectManager()  

then using pm object on the same method?

Cheers

Thanks!

After changing to :

import com.atlassian.jira.component.ComponentAccessor
[....]
ProjectManager pm = ComponentAccessor.getProjectManager()
Project selectedProjectObj = pm.getProjectByCurrentKeyIgnoreCase(selectedOption)

I no longer have the error!

 

Can you also help with the last issue i have?  The "${actors.getUsers()*.name}" resolves all the way down to the users that are members of the group, while i want to only get the group object...

Thanks!

 

After changing to :

 

import com.atlassian.jira.component.ComponentAccessor
[...]
ProjectManager pm = ComponentAccessor.getProjectManager()
Project selectedProjectObj = pm.getProjectByCurrentKeyIgnoreCase(selectedOption)

 

I no longer have the error!

 

Can you also provide a hint on how to get the project role group ? the "${actors.getUsers()*.name}" resolves all the way down to the actual users, and i only want the group object (to be added on the CF "Available groups")

Confirmed!

do you have any suggestion on how to get the group defined on project role?

The "${actors.getUsers()*.name}" resolves all the way down to the actual group members... and i need to add the group to the "Available groups" group picker CF...

miikhy Community Leader Jun 27, 2018

Hi again!

I'd go with https://docs.atlassian.com/software/jira/docs/api/7.1.8/com/atlassian/jira/security/roles/DefaultRoleActors.html#getRoleActorsByType-java.lang.String-

That would allow you to retrieve Group type actors and you can iterate on the set returned to get group names. The String to filter on groups is defined here:

https://docs.atlassian.com/software/jira/docs/api/7.1.8/com/atlassian/jira/security/roles/ProjectRoleActor.html

Should be ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE :)

Hope this helps!

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

97 views 0 5
Read article

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