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

How to get project role using simple script to validate in transition ?

Hello team,


I have added one validation for one field while creating the Issue (issue type = Bug).


if (( == 'Bug') && !cfValues['Regression Bug']) {
return false;
} else {
if (cfValues['Regression Bug']?.value == 'Could not be checked' && !cfValues['Regression Bug Comment']) {
return false;

return true;


Now for one another field I need to check the user is developer and field value is "NOT SET" otherwise return false. 

I will add this code in simple scripted validator.

Please help me with this.




1 answer

Hello Suhas, 

To find the project role you can use the following: 

import com.atlassian.jira.component.ComponentAccessor;

def projectManager = ComponentAccessor.projectManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allProjects = projectManager.getProjects()
def project = allProjects.find(){it.getName() == "Project Name"}

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoles = projectRoleManager.getProjectRoles(user, project)
def memberOf = projectRoles.find(){it.getName() == "Developer"}?true:false

if (memberOf){
*Do stuff*



I am not sure what you mean with field value is not set. Is it a select field with the option "NOT SET" or is it null?

Yes, its a field with value "NOT SET".

So you saying the above code will work in simple scripted validator?

Hi Raskou

I have achieved this using following:

if ((isUserMemberOfRole('Developers')) && cfValues['Management Flag']!= 'NOT SET') {
return false;


return true;

Thanks for your help!



Hello Suhas, 

That's great, glad you got it working!

Suggest an answer

Log in or Sign up to answer

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