Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Project Key by User mail

Yuval Maron
Contributor
August 3, 2021

Hey,
I'm writing a mail handler script using scriptrunner and I need to have the ability of finding the relevant project key by user email. Is that possible?

For example:

Getting the project key which the user(test@test.com) belongs to.

 

Thanks in advance!

1 answer

0 votes
Mohamed Benziane
Community Champion
August 3, 2021

Hi,

I'm not a developer but i think you can do it like that.

Try to get the user using this class:

https://docs.atlassian.com/software/jira/docs/api/7.1.8/com/atlassian/jira/user/UserUtils.html

Then you can use this class

https://docs.atlassian.com/software/jira/docs/api/7.0.3/com/atlassian/jira/security/roles/ProjectRoleManager.html

You may need to use this method for each project role and project in your instance.

getProjectRoleActors(ProjectRole projectRole, Project project)

 

There is maybe a better or quicker solution, i let people who have more knowledge in scriptrunner/groovy give some hint if you need.

Suggest an answer

Log in or Sign up to answer