Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Workflow transition's script condition doesn't work.

Hi,

 

I want to restrict my transition (Approve / Deny) based on which group the current user is a member of.

In order to achieve this I am using the script below 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

def groupManager = ComponentAccessor.getGroupManager()

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

groupManager.isUserInGroup(currentUser, "Murex Task Team")

 

The script returns true/ false when I change the group and when I run this in script console, as expected.

But when I add it to the Workflow Transition condition it always evaluates to true allowing me to complete the transition irrespective of the group specified , please can you suggest what's wrong with the script?

 

I know I can use the build in "User Is In Group "condition  to do this, but I want to extend this to pickup the group name from a Custom field on the issue therefore I am trying this method.

Thanks 

Sar

 

 

1 answer

Hi Sar,

Which version of SR and JIRA are you using? This script works fine for me. Have you made sure that you added the validator to the correct workflow step?

Could you try adding a logging statement to see which groups the currentUser is in?

import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.debug(groupManager.getGroupNamesForUser(currentUser))
groupManager.isUserInGroup(currentUser, "Murex Task Team")

 What is output to the log after using this script as a validator?

Make sure you are using Simple Scripted Condition, or Simple Scripted Validator.  A screenshot would help.

Guys,

I am so sorry for not replying earlier.

The reason it was not working was because I was using Custom script condition  instead of Simple scripted condition.

All good now.
Thank you :)

Custom script condition should work, except if you're on an old version of the plugin. If you are, you need to set passesCondition to a boolean. Simple scripted condition is easier.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you