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

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,847 views 12 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot