Forums

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

Need help with clearing issue Resolution through ScriptRunner

Aisha M
Contributor
October 8, 2024 edited

In our environment, users are NOTallowed to move an issue from DONE to the previous statuses. But, when they accidently do it, I want to run a script to move the issue back to the previous status say 'In Progress".

I am able to move the status back successfully, but the Resolution of the issue still shows as "Done" . . How do I change it to None or "Unresolved" 

Below is a snippet of my code for clearing the Resolution:

 

def issueService = ComponentAccessor.getIssueService()

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def issueInputParameters = issueService.newIssueInputParameters()

issueInputParameters.addCustomFieldValue(IssueFieldConstants.RESOLUTION, null)

def validationResult = issueService.validateUpdate(currentUser, issue.id, issueInputParameters)

if (validationResult.isValid()) {

    issueService.update(currentUser, validationResult)

} else {

    return "Failed to clear resolution: ${validationResult.errorCollection}"

}

2 answers

2 accepted

Suggest an answer

Log in or Sign up to answer
2 votes
Answer accepted
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 10, 2024

Hi,

try to get the issue as a mutableIssue, that will allow you to set the resolution
MutableIssue (Atlassian JIRA 7.6.1 API)

Aisha M
Contributor
October 10, 2024 edited

Thank you ! It took me a long to figure what you just said :) 

0 votes
Answer accepted
Aisha M
Contributor
October 10, 2024

Was able to figure out !

I kept using issueService and tried to rest the resolution via the IssueInputParameters and it did not work.

So instead cleared the resolution directly from the MutableIssue object

TAGS
AUG Leaders

Atlassian Community Events