Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to identify all subtasks with proper value in custom field

Galas September 20, 2019

I would like to identify all subtasks under the user story with proper value in the custom field, The idea is that if such exists than the transition should be disabled.

I have written something like that:

 

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def cf = customFieldManager.getCustomFieldObjectByName("Test type")

def subtasks = issue.getSubTaskObjects().findAll { it.issueTypeObject.name == 'Sub Test Execution' && it.getCustomFieldValue(cf) == "Development test"}

!subtasks.any { subtask -> !subtask.getResolutionObject() }

 

Unfortunately, the list of subtasks is empty and looks that it.getCustomFieldValue(cf) == "Development test" doesn't work. Could you help me with fixing it ?

 

Thanks in advance.

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Ilya Turov
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 20, 2019

looks like "Test Type" is a select type custom field, so when you are trying to compare it to string, it fails hence finding no such subtasks

try replacing it with 

it.getCustomFieldValue(cf)?.value == "Development test"

that should do the trick

Galas September 20, 2019

When I changed it I have received an error "No such property: value for class"

Ilya Turov
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 20, 2019

its typechecking error, don't pay attention

Galas September 20, 2019

It works, thank you a lot

TAGS
AUG Leaders

Atlassian Community Events