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,365,057
Community Members
 
Community Events
168
Community Groups

Workflow Condition not triggering / working

Hi,

 I have a status that has 2 transitions (Peer Review and independence Review. I created a condition based on Overall Impact field (single select). If Overall Impact is High, Independent Review should show and Peer Review should be hidden.

If Overall Impact is either Low or Moderate, Peer Review should show and Independence Review should be hidden.

Selecting Low or Moderate works (Independent Review is hidden) BUT if I select High, Peer Review still shows (transition should be hidden). 

Here's my condition for Peer Review

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf1 = customFieldManager.getCustomFieldObject(30924)
if (issue.getCustomFieldValue(cf1)?.value == "Low" || issue.getCustomFieldValue(cf1)?.value == "Moderate") {
    return true
}
Here's my condition for Idependent Review
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject(30924)
if (issue.getCustomFieldValue(cf)?.value == "High") {
    return true
}
PS:
 I've notice the condition in Peer Review has not run 

 

1 answer

0 votes

The condition may not run if an earlier condition in a group already made a determination (the first one failed in an AND group, or the first one passed in an OR group).

For readability, I'd rewrite your condition like this:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def impactCf = customFieldManager.getCustomFieldObject(30924)
def impactValue = issue.getCustomFieldValue(impactCf)?.value

def showTransition = impactValue in ['Low', 'Moderate']
log.info "impactValue is $impactValue resulting in showTransition=$showTransition"
return showTransition

And

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager
def impactCf = customFieldManager.getCustomFieldObject(30924)
def impactValue = issue.getCustomFieldValue(impactCf)?.value

def showTransition = impactValue in ['High']
log.info "impactValue is $impactValue resulting in showTransition=$showTransition"
return showTransition

Also, with the log statement, you'll see exactly what the script tried to return.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events