You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi Teams,
I am trying to put a validation where a reporter needed to be in the role of say "Business Nominee" to be able to create an issue. I have try the following code but it is not working:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
projectRoleManager.isUserInProjectRole(issue.reporter?.name, "Business Nominee")
Could I have some support?
Thank you in advance.
Best regards,
Jason Li
Hi @Jason Li Ting Chung ,
why do you need this to be a groovy script?
You should be able to handle this request using OOB Jira functionality easily.
You can add Permission validator "Only users with Create Issues permission can execute this transition." on the create transition and then update your permission scheme and set only "Business Nominee" project role has the Create Issues permission.
Hi @Jason Li Ting Chung Please try below code.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def projectManager = ComponentAccessor.projectManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def user = issue.getReporter()
def project = issue.getProjectObject()
def projectRoles = projectRoleManager.getProjectRoles(user, project)
if(projectRoles.find(){it.getName() == "Business Nominee"}){
return true
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Jason Li Ting Chung I am assuming you have scriptrunner installed as you are writing groovy scripts.
Have a look at Advanced workflow configurations here.
It may be worth understanding the difference between conditions and validations.
What you are trying to achieve can be done out the box in Jira workflow configurations and Adaptavast adds a few more features to this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.