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

Your Points Tracker
  • 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
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?
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

How to script only linked issues in a custom email using scriptrunner post function

I'm attempting to pull only the linked issues and not subtasks into a custom email using scriptrunner.

Found this script from a different post:


def outwardlinks = com.atlassian.jira.component.ComponentAccessor.getIssueLinkManager().getOutwardLinks(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 ++
</ul> works, but it is still pulling ALL "linked" issues...subtasks as well as linked tickets from other projects.

How can this be tweaked to only pull linked issues?


1 answer

Hey again! :D

I think you can get the subtasks with a little bit more finesse. ;D

You should be able to get an issue's subtasks directly from the Issue object by doing a call on it like "issue.getSubTaskObjects()". To put this into practice, I coded up an example of how you might want to go about utilizing this when sending a custom email. The finished project looks like this:

Screen Shot 2018-10-26 at 5.17.05 PM.png

Basically, the code in the Condition and Configuration section gets the subtasks from your issue and creates a Map of information about the subtask that you can use; which I've done in the Email template. 

I'll go ahead and place the above lines of code in some code blocks so you can easily copy and paste them for testing:

Condition and Configuration:

import com.atlassian.jira.component.ComponentAccessor

def subtasks = issue.getSubTaskObjects()

//Get values from each subtask
def subtaskInfoList = [:]
subtaskInfoList.put((it.key), [, it.summary])

//Add those values to the configuration to use in the template below
config.subtasks = subtaskInfoList
return true

Email template:


subtasks.each{ key, value ->
out << "$key: Status - ${value[0]} \n"

Try playing around with that jazz and let me know how it goes!

Hope that helped! :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

246 views 2 1
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