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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

92 views 0 1
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