validating issue type and project role.

Hansoo Bae February 8, 2018

I am trying to prevent users in certain project role from creating issues of certain types. 

 

I set condition like this and it's not working (just issues are created)

for example, 

issue.issueType.name in [ 'Epic', 'Story' ] && isUserMemberOfRole('AAA')

my intentions is users in project role 'AAA' cannot create Epic and Story. 

 

Any help will be greatly appreciated.

1 answer

1 accepted

2 votes
Answer accepted
Ivan Tovbin
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.
February 8, 2018

Hi Hansoo,

I assume we are talking about a scripted validator. Try this:

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

def currenUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueTypeName = issue.getIssueType().getName()
def projectRole = ComponentAccessor.getComponent(com.atlassian.jira.security.roles.ProjectRoleManager).getProjectRole("AAA")

if ((issueTypeName == "Epic" || issueTypeName == "Story") && isUserInProjectRole(currentUser, projectRole, issue.getProjectObject()) == true){
throw new InvalidInputException("You don't have the permission to create issues of this type!")
}
Hansoo Bae February 8, 2018

Thank you very much for your answer.

 

This is perfect.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events