Field Behavior - Resolution

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
Accepted answer

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

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

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

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?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,511 views 15 20
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you