how to get custom field data from a cloned issue via script runner

Hi all,

I use Script runner and a scripted send custom email post function for source issue. I would need to get and be able to add in the email's body custom field values of the cloned issue. But I only find codes related to source.issue.

Is there a way to retrieve values of a cloned issue + JIRA References to send them from the parent issue ? I can't find how to define the link of a cloned issue via JQL. I tried "cloners" but it did not work.

Any ideas?

many thanks for your help

Melissa

1 answer

This widget could not be displayed.
Vasiliy Zverev Community Champion Feb 08, 2016

You need to use IssueLinkManager. Here is a code exsample how to find that just one of it is closed

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink

Issue issue = ComponentAccessor.getIssueManager().getIssueObject("ZVER-1")
if(issue == null)
    return "no such issue"

for(IssueLink issueLink: ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())) {
    //if(issueLink.getId() == 34) //place issue link id here
    if(issueLink.getDestinationObject().getStatusObject().getName().equals("Closed"))
        return false
}
return true

Hi,

Thanks for your answer.

As i'm pretty new to this I'm not really to understand where I have to paste this code. Do I have to create a script field to get this value or can I paste it in teh send custom email script ? I tried to do this and the email is not readable.

Just to be sure I'm looking for custom field values which are in issues that have been cloned

Thanks

Hi,

 

i found a pretty similar request as mine : https://answers.atlassian.com/questions/32985921 to which you answered @Vasiliy Zverev

I pasted the code in a script fiedl I created but I don't get any result. I replace the user value with Admin and the custom field ID. For my request, I would like to retrieve the following values from issues that have been linked (in my case, it will be issues which are cloned) to gather them into only one field :

  - JIRA reference of cloned issues

  - one custom field

 

image2016-2-9 14:49:3.png

Could you please help me build this script ?

Many many thanks in advance

Melissa

Vasiliy Zverev Community Champion Feb 10, 2016

Pay attention that there are outward and inward links. Are you sure that you use correct one?

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

47 views 1 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you