Forums

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

How archive a single issue using Groovy?

Rafael Costa
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.
February 14, 2022

I'm trying archive an issue via MyGroovy plugin and I found this code in the community:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.archiving.ArchivedIssueService

@StandardModule
ArchivedIssueService a

def authContext = ComponentAccessor.getJiraAuthenticationContext()
//issue = ComponentAccessor.getIssueManager().getIssueObject("TESTISSUE-1234")
def validationResult = a.validateArchiveIssue(authContext.getLoggedInUser(), issue.getKey());
if (validationResult.isValid()) {
a.archiveIssue(validationResult);
}

 

But when I put this code in the Console, this error appears:

2022-02-14_09-51-53.png 2022-02-14_09-52-54.png

 

How can I fix it ?

1 answer

1 accepted

1 vote
Answer accepted
Fabio Racobaldo _Herzum_
Community Champion
February 14, 2022 edited

Hi @Rafael Costa ,

that method is not more available depending on JIRA version.

Btw, try this one :

validateArchiveIssue(ApplicationUser user, String issueKey, boolean notifyUsers)

def validationResult = a.validateArchiveIssue(authContext.getLoggedInUser(), issue.getKey(), false);

So you need a boolean as last parameter of your call. More information available here

This should fixs your issue,

Fabio

Rafael Costa
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.
February 14, 2022

Thaaanks Fabio it's still works here!

More a doubt: What means @StandardModule in this script?

Like • Fabio Racobaldo _Herzum_ likes this
Fabio Racobaldo _Herzum_
Community Champion
February 14, 2022

Hi @Rafael Costa ,

@StandardModule is an annotation that imports ArchivedImportService module in your script.

Fabio

Like • Rafael Costa likes this

Suggest an answer

Log in or Sign up to answer
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