Get Project Key by User mail

Yuval Maron 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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