Forums

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

Find archived issues for project via Scriptrunner

Jakub Cieplinski
Contributor
March 15, 2022

Hi,

I want to know how can I find all archived issues for a given project using scriptrunner. 

1 answer

1 accepted

0 votes
Answer accepted
Helmy Ibrahim _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 15, 2022

Hi Jakub,

Here is how you can do it from a Script Console:

  1. First, get the project object with ProjectManager.getProjectByCurrentKey.
  2. Then, get all issue ids with IssueManager.getIssueIdsForProject
  3. Get all issue objects for the project with IssueManager.getIssueObjects.
  4. Finally, filter only the archived issues with Issue.isArchived.

Here's an example: 

import com.atlassian.jira.component.ComponentAccessor

def projectManager = ComponentAccessor.getProjectManager()
def issueManager = ComponentAccessor.getIssueManager()

def project = projectManager.getProjectByCurrentKey('TEST')

def issueIds = issueManager.getIssueIdsForProject(project.id)
def issues = issueManager.getIssueObjects(issueIds)

def archivedIssues = issues.findAll { it.isArchived() }

I hope this helps!

Cheers,
Helmy

Jakub Cieplinski
Contributor
March 16, 2022

Yes, that's exactly what i was looking for, thank you

Suggest an answer

Log in or Sign up to answer