Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Validate whether user is part of group a||group b when item is created via simple scripted validator

My client wants to restrict item creation to people of two teams.

Due to the circumstances I can't work with simple permissions.

The client is using scriptrunner for other projects; So my initial thought was to leverage that.

By using a simple scripted validator in the "create" transition I want to check whether the current user is part of group a or group b, if it validates to true, the item can be created.


I am a total groovy script noob, so naturally I've done some digging and came up with the following groovy "script":

import com.atlassian. jira.components.ComponentAccessor
if(ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "group name a")){}
else if(ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "group name b")) {}

 Which does not work.

Regardless of it working as intended or not, it also doesn't display the error message I provided in the ssv.


What am I doing wrong? Is there a better solution, do I just need to adjust the script?

1 answer

0 votes
Leo Community Leader Nov 22, 2019

Hi @Luke,

you can do that using below steps --> Script Validator --> Simple Script Validator

source: code

Error: your error message

Field: Issue Type


I'm attaching snippet for your reference, here I'm not allowing "Group-A" members to create "Story", you can modify this code according to your requirement

import com.atlassian.jira.component.ComponentAccessor 

def groupManager = ComponentAccessor.getGroupManager()

if(groupManager.isUserInGroup(issue.reporter?.name, 'Greoup-A') && ! == "Story"){
return true
return false




Hi Leo


Thanks for your input.

I have adapted my simple scripted validator to your code, exchanging some parts and leaving others out.

After publishing the workflow on the clients test environment, it successfully blocks me from creating an issue, since I'm in neither of the groups. But the error message still isn't getting displayed, it just doesn't create the issue; Just like when you leave a required field empty.

I am starting to think that it might be an issue with the clients setup of jira and scriptrunner itself.

Leo Community Leader Nov 24, 2019


if you are using "Simple Script validator", have you filled below 2 fields?

1. Error Message:(error to display users)

2. Field:(under which field error message should appear)

if you are using "Custom Script validator", use below snippet instead of "return false" statement

import com.opensymphony.workflow.InvalidInputException // importing exception page to handle

throw new InvalidInputException("custom error message") // instead of return false




Hi Leo

I am using the "simple scripted validator", and yes I've got the two fields "error message" and "field" set to the respective values.

The validation seems to work, as it does not allow me to create items anymore (since I'm not part of that usergroup), but there's never an error message.

Leo Community Leader Dec 12, 2019

You can try with custom error handling, maybe my previous update can give you some idea/reference 

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