Forums

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

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
Leo
Community Champion
March 6, 2020

Hi @khalid alqahtani,

Below script may give you some idea, I haven't tried by myself so may require some minor changes

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.project.version.VersionManager

def projectManager = ComponentAccessor.getProjectManager()
def project = projectManager.getProjectObjByKey("KEY")

def versionManager = ComponentAccessor.getVersionManager()

versionManager.createVersion("Version Name", new Date(), new Date()+7, "New Version Description",project.id, null)

BR,

Leo

khalid alqahtani
Contributor
March 6, 2020

Thank you, very helpful.

TAGS
AUG Leaders

Atlassian Community Events