Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,636
Community Members
 
Community Events
185
Community Groups

need to add Script condition for project role on transition

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.

2 answers

1 accepted

1 vote
Answer accepted
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

Hi @Admin 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.

Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

@Admin  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


Like Admin likes this

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.

Like Vikrant Yadav likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

@Admin  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
Like # people like this

@Vikrant Yadav Thanks a lot for your support.

Like Vikrant Yadav likes this
Vikrant Yadav
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

Hi @Admin kindly accept the solution.

0 votes
Sebastian Krzewiński
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

Hi @Admin 

 

Did you try to use 'User Is In Project Role' condition?

 

Regards,

Seba

yes , I tried still not working

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events