Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Parent Linked Issue Summary on Subtask Edited

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

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
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

101 views 0 6
Read article

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