Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

Concatenate field values from n number of Subtasks to parent using groovy script

MK
Contributor
April 29, 2020

Parent issue Type: Sub Engagement
Child issueType: Contract details.

A parent issue can have n number of subtask(child issue).
Each subtask has a field "oracle project #".

Requirement: I need to append or concatenate the field value of each subtasks to it parent issue.

Below is my script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.SubTaskManager

SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();

def cfm = ComponentAccessor.getCustomFieldManager()
Collection subTasks = issue.getSubTaskObjects()

def CD_concatenated = new StringBuffer()

for (currIssue in subTasks)
if (currIssue.getIssueType().name == "Contract Detail")
{
subTasks.each

{ def CD = it?.getCustomFieldValue(cfm?.getCustomFieldObjectByName("Oracle Project #")) CD_concatenated.append(CD + "," + " ") }

}

return CD_concatenated.toString()

I'm getting null values: this might because it is looking for subtask that is not contract details.

and the result is repeating it self..

What am I missing here, how can make the script look for contract details alone.

1 answer

0 votes
MK
Contributor
April 29, 2020 edited

Below is the output for what I tried, can seems to find What I'm missing!!script.JPG

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Upcoming Jira Service Management Events