how to get the key of a linked issue in the email body when you use "Send custom email" script post-function


I want to use a "send custom email" post-function with script runner. In the body of my email, I would like to get the issue key of eventual linked issue.

Any ideas please ?



3 answers

I used the following code in the "Email template" section. It loops through the Linked Issues and builds out a list of linked issues (Please excuse the code as I don't claim to be a developer by any means :)).

I hope this helps.  ...Cheers!

 <b>Linked Issues:</b> <br>


def outwardlinks = com.atlassian.jira.component.ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())
def inwardlinks = com.atlassian.jira.component.ComponentAccessor.getIssueLinkManager().getInwardLinks(issue.getId())
def oCounter=0
def iCounter=0

// Check for Outward Links...
if (outwardlinks)

for (id in outwardlinks) {
def linkedissueKey = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(outwardlinks[oCounter].destinationId).key
def linkedissueSummary = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(outwardlinks[oCounter].destinationId).summary
def linkedissueStatus = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(outwardlinks[oCounter].destinationId)

out << "<li><a href='"+linkedissueKey+"'>"+linkedissueKey+"</a> "
out << "("+linkedissueStatus+"):"
out << linkedissueSummary+"</li><br>"

oCounter ++

// Check for Inward Links...
if (inwardlinks)

for (id in inwardlinks) {
def linkedissueKey = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(inwardlinks[iCounter].sourceId).key
def linkedissueSummary = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(inwardlinks[iCounter].sourceId).summary
def linkedissueStatus = com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(inwardlinks[iCounter].sourceId)

out << "<li><a href='"+linkedissueKey+"'>"+linkedissueKey+"</a> "
out << "("+linkedissueStatus+"):"
out << linkedissueSummary+"</li><br>"

iCounter ++




You can get all linked issues like this


Hi both, @Jamie Echlin [Adaptavist] @Vasiliy Zverev


thanks for your answer. Do not pay attention to the "eventual" liked issues. sorry it was confusing and does not matter.

here is my email and what I tried to show the linked issue reference thanks to Vasiliy's comment: (send custom email post-function script). But it returned into a script error. Any ideas? thanks for your help



<p>Dear all,</p>

<p>For your information, this NPC study has been reviewed with your teams. Please find attached the detailed Impact Analysis.</p> <p>You can also log in directly our tool JIRA: <a> "$issue.key"</a></p>

<p>Summary: ${issue.summary}</p>

 <p>Description: ${issue.description}*</p>

<p>SCOPE restriction:</p>

 <p>CAP volume:</p>

<p>First trade planned:</p>

<p>IT development:</p>

<p><% out << issue.getCustomFieldValue(componentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())%></p>

<p>Best Regards,</p>

<p>NPC team


Can you remove the "issue.getCustomFieldValue", not sure why you have that.

What does "eventual linked issue" actually mean? This can be quite complex.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

211 views 4 1
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