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

Hi,

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 ?

Thanks

Melissa

3 answers

You can get all linked issues like this

ComponentAccessor.getIssueLinkManager().getOutwardLinks(issue.getId())

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> "https://aptp-alm.accenture.com/jira/browse/$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.

0 votes

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

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>

<ul>
<%

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).status.name

out << "<li><a href='https://jira.domain.com/browse/"+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).status.name

out << "<li><a href='https://jira.domain.com/browse/"+linkedissueKey+"'>"+linkedissueKey+"</a> "
out << "("+linkedissueStatus+"):"
out << linkedissueSummary+"</li><br>"


iCounter ++
}

%>

</ul>

 

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,007 views 5 18
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot