Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get epic tasks in script filed

Katarzyna Kacperska April 16, 2024

I'm using Script Fields in Script Runner.

For an epic I want to display any information from its tasks.
To download these tasks I use the command:

def links = issueLinkManager.getOutwardLinks(issue.id)


but this returns me not only issues in epic but also other issues linked to it.

How to get only issues which are connected via thic Epic by epic link ?

2 answers

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 16, 2024 edited

Hi @Katarzyna Kacperska

The approach you are trying alone will not work.

You need to perform other steps for the filtration to work correctly.

Below is a sample working code for your reference:-

import com.atlassian.jira.component.ComponentAccessor

def issueLinkManager = ComponentAccessor.issueLinkManager

if (issue.issueType.name == 'Epic') {
def listOfTasks = issueLinkManager.getOutwardLinks(issue.id).collect { issueLink ->
if (issueLink.destinationObject.issueType.name == 'Task') {
issueLink.destinationObject
}
}.findAll {it != null}

listOfTasks
} else {
return
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the Scripted Field configuration:-

scripted_field_config.png

Below is a test output:-

If you observe the screenshot below, as configured in the Scripted Field code, it will only display all Task issue types that belong to the epic.

test.png

 

I hope this helps to solve your question. :-)

Thank you and Kind regards,
Ram

Ram Kumar Aravindakshan _Adaptavist_
Community Champion
April 17, 2024

Hi @Katarzyna Kacperska

Great to hear the solution worked for you. :-)
Please accept the answer provided.


Thank you and Kind regards,
Ram

0 votes
Katarzyna Kacperska April 17, 2024

Hi Ram,

Thank you very much for your answer. I used this commands:

def links = issueLinkManager.getOutwardLinks(issue.id)
links.each { issueLink ->
       
        if (issueLink.issueLinkType.name == "Epic-Story Link") {  
...

but the solution you provided is better.

Regards,

Kate

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, loom, loom for training, loom for teaching, video training, async learning, online education, screen recording, loom tutorials, loom use cases, atlassian learning, team training tools, instructional video, virtual training tools

🛗 Elevate Your Training and Enablement with Loom

Join us June 26, 11am PT for a webinar with Atlassian Champion Robert Hean & Loom’s Brittany Soinski. Hear tips, stories, and get your burning questions answered. Learn how Loom makes training and enablement easier. Don’t miss it!

Register today
AUG Leaders

Atlassian Community Events