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

0 vote
Vasiliy Zverev Community Champion Mar 02, 2016

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 vote

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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

770 views 3 11
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