Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Condition not triggering / working

Joel Batac
Contributor
September 15, 2022

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
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 15, 2022

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