Forums

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

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

fjodors
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2014

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

1 vote
Answer accepted
Svante Gustafsson Björkegren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2014

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

Svante Gustafsson Björkegren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2014

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

fjodors
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2014

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

0 votes
Alex Gubar October 12, 2017 edited
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!")
}
}
}
Alex Gubar October 12, 2017

But this is not work...

Rafael Fernandez Coelho November 13, 2020

hello,

i use cloud version, so i dont know if what i will say applies to your case.

since it is a validator, i believe it does not accept "if" (at least I could't use until now), it is only possible to use jira expressions or something like that.

but you dont need 3 if, because it will only permit the creation (or whatever you are validating) when all is true, right? so you can use all of them ia a single line joined by AND (&&)

issue.projectObject.key == 'ProjectA'
&&
issue.issueType.name == 'Task'
&&
isUserMemberOfRole('Manager')

something like this i believe

 

and thanks, i was looking for something that could validate if the user has some role in the project!

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events