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:
<ul>
<%
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).status.name
out << "<li><a href='https://jira.domain.com/browse/"+linkedissueKey+"'>"+linkedissueKey+"</a> "
out << "("+linkedissueStatus+"):"
out << linkedissueSummary+"</li><br>"
oCounter ++
%>
</ul>
...it 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?
Thanks
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:
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 = [:]
subtasks.each{
subtaskInfoList.put((it.key), [it.status.name, it.summary])
}
//Add those values to the configuration to use in the template below
config.subtasks = subtaskInfoList
return true
Email template:
Issue:
${issue.key}
Subtasks:
<%
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! :)
Aidan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.