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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Parent Linked Issue Summary on Subtask


Good Night,

I'm trying to do a post function script where on the crating of a subtask, I get the parent linked issue summary in to a custom field.

I got an issuetype name "SS", the "SS"is linked to the issuetype named "Projeto", then I create an subtask (Called "RM") on the issuetype "Projeto".

I want that the summary of "SS" gets in the field "Summary SS" on the subtask "RM".

I did a script but it only gets the parent summary, not the linked summary.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.ImmutableCustomField
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def log = Logger.getLogger("com.acme.CreateSubtask")

//instancias de objetos necessarios
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subtaskManager = ComponentAccessor.getSubTaskManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//pega usuario logado
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//pega a key da issue pai da subtaks
def parentIssue = issue.getParentObject()?.getKey()
log.error("issue Parente" + parentIssue)
def parentObject = issueManager.getIssueObject(parentIssue)
log.error("Issue Object"+ parentObject)
//instancia de link manger para pegar os links
def linkManager = ComponentAccessor.issueLinkManager

def issueKeys = []
//id do campo que sera preenchido com o valor do campo da issue linkada
long idFieldPreencher = 10813
// campo que ira receber o valor da issue linkada

//long idCampoComValorDesejado = 10502

def fieldPreencher = customFieldManager.getCustomFieldObject(idFieldPreencher)

//def campoComValorDesejado = customFieldManager.getCustomFieldObject(idCampoComValorDesejado)

//percorrer todos os links da issue da postfunction

//cria variavel com o destination(issue que esta linkada como destno)
def linkedIssue = it.sourceObject

//cria objeto com o id da issue linkada
def linkedIssueObject = issueManager.getIssueObject("${linkedIssue}")

log.error("linked" + linkedIssueObject.getId() + " Issue "+ linkedIssue)
String newSummary =linkedIssueObject.getSummary()
//String newSummary = issue.getSummary(cFieldE)
log.error("newSummary" + newSummary)

//verifica se a issue linkada e do issue type desejado
// if(linkedIssueObject.getIssueTypeId().equals("10004")){
// def valorCampo = linkedIssueObject.getCustomFieldValue(campoComValorDesejado)
// log.error("entrou na condicao")
//coloca o valo desejado da issue lincada no campo criado na lina 21
// issue.setCustomFieldValue("customfield_10813", linkedIssue.newSummary)

def changeHolder = new DefaultIssueChangeHolder()
fieldPreencher.updateValue(null, issue, new ModifiedValue(fieldPreencher, newSummary),changeHolder)

// da um update na issue com o valor novo do campo
// issueManager.updateIssue(user, issue, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_UPDATED, false)



1 answer

Oi Debora!

Será que não daria para fazer com um Script Field?

O issuetype Projeto capturando o summary da SS e populando esse Script Field, e na sequência você poder usar um script para a sub do "Projeto" poder capturar esse valor? 


Could not you do with a Script Field?

The issuetype "Project" capturing the SS summary and populating this Script Field, and in the sequence you can use a script for the subtask of the "Project" to be able to capture that value?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events