Forums

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

Postfunction error

John Peterson March 28, 2018

Hello everyone. I want to update Resolution field using Groovy. For example

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ResolutionManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.security.JiraAuthenticationContext
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.config.ConstantsManager


def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)
// MutableIssue issue = issue;
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext();
User loggedUser = jiraAuthenticationContext.getLoggedInUser()
issue.setResolutionObject(ResolutionManager.getResolutionByName("Done"));

 

But I see an error 

groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.config.ResolutionManager.getResolutionByName() is applicable for argument types: (java.lang.String) values: [Done]
	at Script3148.run(Script3148.groovy:13)

 

1 answer

0 votes
Ivan Tovbin
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 28, 2018

Hi John,

That's because you need to call getResolutionByName() method from an instance of Resolution Manager interface. Looking at your code and instance of this interface is stored in resolutionManager variable, so the correct code would be:

issue.setResolutionObject(resolutionManager.getResolutionByName("Done"));

(note the lower case 'r' in 'resolution) :)

On a side note, I've noticed that you've declared the wrong type for loggedUser variable. The correct way would be:

import com.atlassian.jira.user.ApplicationUser

ApplicationUser loggedUser = jiraAuthenticationContext.getLoggedInUser()
 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events