It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

What is your question?

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

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)

}

is there a way I Can debug my script.?

use log.error()

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

ava.lang.NullPointerException: Cannot invoke method getSummary() on null object

This is the error I am receiving in exceptiono

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

@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
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you