Set Resolution using Script Runner Post Function

Ameet Shah August 5, 2016

I am trying to set the resolution on transition with the condition if resolution is not set or blank , put it to "Done".

Implementation 1:

 

import com.atlassian.jira.config.ResolutionManager

 

if (issue.getResolutionObject() == null) {

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

}

Fails with message that getResolutionByName does not exist


Implementation 2: (debug method to see if Done exists and is accessible)

 

import com.atlassian.jira.config.ResolutionManager

import com.atlassian.jira.config.ConstantsManager

 

if (issue.getResolutionObject() == null)

{

    for (each in ConstantsManager.getResolutionObjects())

    {

        if (each.getName() == 'Done')

        {

            issue.setResolutionObject(ResolutionManager.getResolution(each.getId()));

        }

    }

}

 

Can any one please suggest whats wrong or how i can make Implementation 1 work.

1 answer

1 accepted

7 votes
Answer accepted
JamieA
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.
August 7, 2016
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ResolutionManager

def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)

if (! issue.getResolutionObject() ) {
    issue.setResolution(resolutionManager.getResolutionByName("Done"))
}
graemejohnson August 28, 2019

Thanks - this was just what I needed

Jarrod Moura October 1, 2019

This doesn't work for me.

asorek October 13, 2019

add command:   issue.store()

after the assignment

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events