Script Runner Condition in Workflow transitions


I am trying to set criteria on when a transition is allowed in a certain workflow. Its based on two conditions -

1) Custom Select Field value

2) user needs to be part of a certain group


The following is a "Custom Script Condition" I added on the transition condition.

There are no syntax errors in the following but I dont see the expected behavior -

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def DBCCTypeCf = customFieldManager.getCustomFieldObject("customfield_12323")
def DBCCType = issue.getCustomFieldValue(DBCCTypeCf)


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

if (DBCCType == "Data Update") {
if (groupManager.isUserInGroup(currentUser, "Team DBCC Approver")) {


I have a suspicion that its to do with this check -

if (DBCCType == "Data Update") {

This doesnt work for Issues where this criteria is true.




1 answer

I assume that DBCCType is selected list type. Since here is a refactored code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option

Option DBCCType = (Option) issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12323"))
passesCondition = false

if (DBCCType.getValue() == "Data Update") {
    def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser().directoryUser
    if (ComponentAccessor.getGroupManager().isUserInGroup(currentUser, "Team DBCC Approver")) {

Works great! I guess it was the type casting that I was missing.

I appreciate your help!


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

457 views 8 27
Read article

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