Hi All,
what should be the script for project role(like: Tester) condition on transition?
Means, only testers would be visible on particular transition.
I was trying this : isUserMemberOfRole('Testers') , but it's not working.
Thanks.
Hi @Pankaj You are trying to set up a condition, users which are in Tester project role only have permission to transition this issue, right ?
Instead of writing a scripted condition, you can this Condition Project role(s) condition [ScriptRunner] : Allows the transition if the current user is, or is not, a member of the specified project role(s).
yes , this condition is working , but I want to try through writing the script i.e , inline script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Pankaj I think you are trying to add Custom Scripted Condition, for this try below script :-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def projectRoleManager = ComponentAccessor.getComponentOfType(com.atlassian.jira.security.roles.ProjectRoleManager)
def testerRole = projectRoleManager.getProjectRole("Tester")
def project = issue.getProjectObject()
def userInTesterRole = projectRoleManager.isUserInProjectRole(currentUser, testerRole, project)
log.warn userInTesterRole
passesCondition = userInTesterRole
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes its working , but could you please exlain the code step by step that will be very clear understanding for me or else we can able to write next condition or something by ourself.
Thank You very much.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Pankaj Glad to hear I am able to help you out! Kindly accept the solution, if works for you as it helps other users looking for same solution.
Detailed Description :-
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
//get Current User/logged in User
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//get project roles
def projectRoleManager = ComponentAccessor.getComponentOfType(com.atlassian.jira.security.roles.ProjectRoleManager)
//get Tester roles from Project Roles
def testerRole = projectRoleManager.getProjectRole("Tester")
//get Project Key
def project = issue.getProjectObject()
//check if user in Tester project role or not, it gives true or false value and value stores in variable userInTesterRole
def userInTesterRole = projectRoleManager.isUserInProjectRole(currentUser, testerRole, project)
log.warn userInTesterRole
//pass condition if userInTesterRole is true , fail if userInTesterRole is false
passesCondition = userInTesterRole
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.