Condition: Current User in Role X and custom field == Y

Hi,

I try to add a simple script to a workflow transition.

I want only let the current user transition the issue if he is in a specific role and at the same time the value of a multi select field has the value "y".

Is this possible?

 

1 answer

This widget could not be displayed.

Hi there,

So the condition for the specific role (and assume you mean a project role)

Issue issue = issue
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def roleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectRole = roleManager.getProjectRole("Administrators")
 
//if project role Administrators does not exist return false
if (!projectRole)
    return false

//will return true or false if the user is in Administrators role
def isInRole = roleManager.getProjectRoleActors(projectRole, issue.getProjectObject())?.getApplicationUsers()?.contains(user)
 
//the value of a multi select field has the value 'My value'
def hasValue = 'My value' in cfValues['My Multi List']*.value
 
//or any other combination
return isInRole && hasValue

regards, Thanos

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

576 views 25 15
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you