Script Runner - Restrict creation of specific issue type for specific users/groups/project

Hello

I am looking for ability to restrict creation of specific issue type for specific users/groups/project.

I found that the easiest solution is a Script runner validator in workflow "create transition"

So I need the condigition:

if

issueType="IssueType" && user who is creating this issue is member Of Role("Project Role") && project is "PROJECTKEY"

returns true, then issue could not be created.

1) issue type condition is

issue.issueTypeObject.name == 'Bug'

2)project role condition is

isUserMemberOfRole('Administrators')

3) I am not able to find condition for project. I tried

issue.getProjectObject().key == "ABCD-123", but it doesn't work.

Is there a possibility to find a project key? I need to merge these three conditions.

Thank you in advance,

Fyodor

2 answers

1 accepted

Hello Fyodor,

Use the following syntax to grab the project in your condition:

issue.projectObject.key == 'ABCD'

The complete condition would look something like:

issue.projectObject.key == 'ABCD' && isUserMemberOfRole('Administrators') && issue.issueTypeObject.name == 'Bug'

Hope this helped!

Cheers,

// Svante

btw: I re-tagged your question to more correct tags. Hope you don't mind :-)

Hello Svante

Thank you for info.

I need to check three conditions, so it seems I need creat multi-level condition, e.g.

if(issue.issueTypeObject.name == 'Bug'){
if(issue.projectObject.key == 'ABCD'){
if(!isUserMemberOfRole('Administrators')){
invalidInputException = new InvalidInputException("Invalid condition!")
}
}
}

In all others situation issue can be created

Is it possible to put such exression in script runner validator?

regards,

Fyodor

import com.opensymphony.workflow.InvalidInputException

if(issue.projectObject.key == 'ProjectA'){
if(issue.issueType.name == 'Task'){
if(!isUserMemberOfRole('Manager')){
invalidInputException = new InvalidInputException("Task can create Manager only!")
}
}
}

But this is not work...

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,129 views 13 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot