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 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.
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 ,
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.