Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,214
Community Members
 
Community Events
165
Community Groups

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

0 votes

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')

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS

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