Forums

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

Resolutions per issue types/projects with help of ScriptRunner

Oleksandr Chalyi
Contributor
July 31, 2018

Hi,

We would like to add a lot of additional Resolution values that will be used by specific issue type -Bug, however it shouldn't affect (be available to) the rest of issue types.
Since we are running over 300 projects, we would like to avoid a lot of manual job - configuring workflows properties.
I fount a hint here:
https://jira.atlassian.com/browse/JRASERVER-65924
As it was mentioned by Roger, script runner may help to achieve this goal. So I added behaviour and following code to Initialiser:

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.RESOLUTION

if (getAction() != null) {

    def constantsManager = ComponentAccessor.getConstantsManager()

   def allowedResolutions = constantsManager.getResolutions().findAll {

        it.name in ["Fixed", "Won't Fix", "Duplicate", "Incomplete", "Cannot reproduce", "Invalid", "Done", "Resolved", "Won't Do", "To Decide"]   

}    getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)}

I'm getting error message {Static type checking} - Cannot find matching 

method com.atlassian.jira.config.ConstantsManager#getResolution(). Please check if declared type is right and if the method exists.

We are running Jira 7.6.4.

1 answer

1 accepted

0 votes
Answer accepted
Mark Markov
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.
July 31, 2018

Hello @Oleksandr Chalyi

Check your code and it works

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.RESOLUTION

if (getAction() != null) {

def constantsManager = ComponentAccessor.getConstantsManager()

def allowedResolutions = constantsManager.getResolutions().findAll {

it.name in ["Fixed", "Won't Fix", "Duplicate", "Incomplete", "Cannot reproduce", "Invalid", "Done", "Resolved", "Won't Do", "To Decide"]

}
getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)}

But this is bad

}    getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)}

place getFieldById on the new line.

And you can try to ignore static type checking. Because it happens because compiler doesnt know about dynamic objects at this stage, but in runtime will be work well.

Oleksandr Chalyi
Contributor
August 1, 2018

Thank you, Mark, for your prompt response. It works.

Mark Markov
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 1, 2018

You re welcome! If it helps you, please mark answer as accepted. So that, other people will be able to find this answer easily for similar questions :)

Suggest an answer

Log in or Sign up to answer