JIRA 7.2 ScriptRunner Behavior to show subset of Resolutions for one project

Michelle Larson
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.
October 6, 2016

I have over 30 resolutions and one of the groups is asking to only show a subset of those when they click resolution.  I was able to get something similar to work for the priority but can't seem to figure out how to do the resolution the few links I have found just say use a behavior (this I know as it is what I used for priority) however I am not seeing any examples for it so I am at a loss.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Kristian Walker _Adaptavist_
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 7, 2016

Hi Michelle,

I have attached a script which I have used to only show a subset of resolutions to all users in a group as a Behaviours script below.

The script uses the jira-software-users group as an example but this can be replaced with the group inside your instance. This has been tested on my local JIRA 7.2.2 instance running ScriptRunner 4.3.9.

Code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.user.UserManager

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

def constantsManager = ComponentAccessor.getConstantsManager()

def userUtil = ComponentAccessor.getUserUtil()
log.debug ComponentAccessor.getComponent(UserManager)

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (userUtil.getGroupNamesForUser(currentUser.name).contains("jira-software-users")) {

    def allowedResolutions = constantsManager.getResolutionObjects().findAll {
        it.name in ["Won't Do", "Duplicate", "Cannot Reproduce"]
    }.collectEntries {
        [(it.id): it.name]
    }

    getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)
}

 

Config:

Screen Shot 2016-10-07 at 15.06.59.png

I hope this helps.

Thanks

Kristian

Michelle Larson
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.
October 7, 2016

Worked perfectly thank you

Kristian Walker _Adaptavist_
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 7, 2016

Glad I was able to help.

Thanks

Kristian

1 vote
adammarkham
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.
October 7, 2016

Theres an example here of how to do that using behaviours.

You need to add the Resolution field in your behaviour and then click add serverside script to attach that script.

Essentially what you want is: 

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

def constantsManager = ComponentAccessor.getConstantsManager()
def allowedResolutions = constantsManager.getResolutionObjects().findAll {
	it.name in ["Won't Fix", "Incomplete", "Cannot Reproduce"]
}

getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)

 

 

0 votes
Steven F Behnke
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.
October 6, 2016

You can do this out of the box with JIRA by using Workflow Transition Properties. 

Adding the properties jira.field.resolution.exclude or jira.field.resolution.include to the Transition where the Resolution field is being presented allow you to exclude specific or to include specific resolutions, respectively. 

https://confluence.atlassian.com/adminjiraserver071/workflow-properties-802592825.html

TAGS
AUG Leaders

Atlassian Community Events