Forums

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

Update the Summary of Sub Task, it should be same as Parent

Anubhav.Agrawal December 4, 2019

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.fields.FieldManager
import com.atlassian.jira.issue.Issue

// Parent Task Summary
def parentTaskSummary = issue.getParentObject().getSummary()

// getting the list of sub task
Collection<Issue> subTasksList = issue.getSubTaskObjects()

// iterating on the list of sub tasks
for(subTask in subTasksList){
def value = subTask.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Component/s"))

}

1 answer

1 accepted

0 votes
Answer accepted
Damian Wodzinski
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.
December 4, 2019

What is your question?

Anubhav.Agrawal December 4, 2019

I want to update the Summary in Sub Task from Parent Task

Damian Wodzinski
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.
December 4, 2019

You can use .setSummary() method: https://docs.atlassian.com/software/jira/docs/api/8.4.1/




def parentTaskSummary = issue.getParentObject().getSummary()
Collection<Issue> subTasksList = issue.getSubTaskObjects()
for(subTask in subTasksList){
MutableIssue missue = ComponentAccessor.getIssueManager().getIssueObject(subTask.getKey());
missue.setSummary(parentTaskSummary)

}
Anubhav.Agrawal December 4, 2019

is there a way I Can debug my script.?

Damian Wodzinski
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.
December 4, 2019

use log.error()

log.error(parentTaskSummary) should show you the data stored in the variable in the logs.

Anubhav.Agrawal December 4, 2019
ava.lang.NullPointerException: Cannot invoke method getSummary() on null object

Anubhav.Agrawal December 4, 2019

This is the error I am receiving in exceptiono

Damian Wodzinski
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.
December 4, 2019

How you access the issue? Are you using the script listener or maybe you are running script in console? If it is the script listener, which event fire it up?

Like Anubhav.Agrawal likes this
Anubhav.Agrawal December 6, 2019

It works 

Harish_Kumar May 20, 2020

@Damian Wodzinski  ,

I am getting an error:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.MutableIssue

Issue issue = event.issue


if (issue.getIssueTypeId() != "17319") {
//log.info "not a Build"
return
}

def changeStartDate = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field=="Build Name / SW Version"}

if (changeStartDate){
// get newly set value for Start date
def CFStartDate = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_24992") // Start date
def CFVStartDate = CFStartDate.getValue(issue)

Collection<Issue> subTasksList = issue.getSubTaskObjects()
for(subTask in subTasksList){
MutableIssue missue = ComponentAccessor.getIssueManager().getIssueObject(subTask.getKey());
missue.setSummary(CFVStartDate)

 

 

//////////errormessageat/// missue.setSummary(CFVStartDate)

check if the declared type is correct and if the method exists

Suggest an answer

Log in or Sign up to answer