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, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events