Field Behavior - Resolution

Chris Volker September 21, 2015

I'm trying to restrict the behavior via the Script Runner Plugin for the "Resolution" field options.  My objective is to restrict the options below to just one project (Other projects would have all options).  I have got this working r one transition (per the web page example) but I want to widen that to the entire workflow if possible so that whenever the resolution field is selected you only get the five options shown below.  I believe I need to change the line "if (getActionName()" but I'm sure what that value should be:

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

if (getActionName() == "The Transition Name") {
def constantsManager = ComponentAccessor.getConstantsManager()
def allowedResolutions = constantsManager.getResolutionObjects().findAll {
it.name in ["QA Verified", "Approved", "Manager Approved", "CRB Approved","Emergency Approved"]
}.collectEntries {
[(it.id): it.name]
}

getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)

Thanks in advance for any assistance someone can provide.

 

3 answers

1 accepted

1 vote
Answer accepted
Taha Khanzada
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.
September 21, 2015

Hi Chris,

How about adding all Transitions where Resolution field is available in project something like this

if (getActionName() == "Resolved" || getActionName() == "Agree to close") {

}

Taha

Chris Volker September 22, 2015

I'm going to try this as a variant on the project. Thanks very much!

0 votes
Mark McCormack _Adaptavist_
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, 2015

When you configure any Behaviour, you can set the "Mapping" which helps you map the projects and issue types it is applied to. I take it you want to apply it to All project and issue types and do this programmatically - which is why you asked the question - right?

0 votes
Christian Czaia _Decadis AG_
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.
September 22, 2015

Hi Chris,

 

if I get you right, you want to limit the resolutions shown to the user. You don't need behaviours for that.

Simply put the following propertiy on the transition where you want to limit the options:

Key: jira.field.resolution.include  Value: 1,2,3<...>

The value is the ID of the resolution. You can find that in the DB or when you go to Resolutions: Hover over the configure button and look at the status bar in your browser. The last number is the ID you're looking for!

https://confluence.atlassian.com/jira/workflow-properties-189949.html

Cheers

Christian

Suggest an answer

Log in or Sign up to answer