Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Scriptrunner post-function custom email template - Linked issue mentioned in Email template

Edited

Hi atlassian community, 

we would like to send a custom notification to a customer when a specific transition was triggered. We have now several postfunctions working,  the first one is a script runner post function cloning the contents of the issue to a new issuetype and linking it to the issue. 

The second function should send a notificiation mail, that the issue is being moved to the issue XX-XXX. The template is working fine, but I have no idea on how to mention the newly created linked issue within the customer notification. 

 

Has somebody solved a related issue?

Edit: 

I found a function that maybe helps, but still not idea how to put that correct within the email template:

issueFunction in linkedIssuesOf("status = Open", "blocks") and resolution is empty

 

1 answer

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 25, 2022

You don't need to use the JQL. That's a bit round-about.

You just need to use the issueLinkManager to find the linked issue.

In your "Condition and Configuration" box add the following

def linkedIssues = issueLinkManager.getLinkCollectionOverrideSecurity(issue).allIssues
if(!linkedIssues){
//this will skip the execution of the send mail post function since no linked issue were found
//it probably means something when wrong in your earlier postfunction to create the linked issue
return false
}

config.lastLinkedIssueKey = linkedIssues.last().key

//make sure the condition returns true to trigger the rest of the send mail postfunction
return true

 

Then, in your Email Template, you can include any parameters added to "config"

Here is the body of your email
Where you might want to include ${config.lastLinkedIssueKey}

If you don't want to just blindly return the last linked issue, you can examine the information you get from getLinkCollectionOverrideSecurity() and filter by link type. Or examine the full list of issues and filter by status or other attributes.

E.g 

//only get the linked issues wihtout resolution
def filteresLinkedIssues = linkedIssues.findAll{ !it.resolution}
//only get the linked issues with status filer
def filteresLinkedIssues = linkedIssues.findAll{ it.status.name=='Open'}
//filter based on link type... you might want to look at getInwardLinks instead
def blockers = issueLinkManager.getLinkCollectionOverrideSecurity(issue).getOutwardIssues('Blockers')

Thanks for your example. It works perfectly :)

Suggest an answer

Log in or Sign up to answer