Missed Team ’24? Catch up on announcements here.

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

Parent Linked Issue Summary on Subtask

Debora (e-Core)
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2019

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")
log.setLevel(Level.DEBUG)

//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
linkManager.getOutwardLinks(parentObject.id).each{

//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

Suggest an answer

Log in or Sign up to answer
0 votes
EduardoS March 12, 2019

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?

TAGS
AUG Leaders

Atlassian Community Events