Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to restrict Resolutions the example script from script runner does not work.

Hello,

Using Jira 8.13.1 Server

I have a project where the use wants to restrict the number of Resolutions available. The total list of Resolutions available are over 25. This is too many,

So one project wants to restrict this for all issue types. The workflow has 8 statuses and they allow any status to transition to any other status.

I copied the script from the scriptrunner website and changed it but for some reason this is not working on the view Issue. It only works when i am in the Edit ticket screen.
This is strange because Create, View and Edit are all the same screen.


I have the following script:

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"]
    }.collectEntries {
        [(it.id): it.name]
    }
getFieldById(RESOLUTION).setFieldOptions(allowedResolutions)



2 answers

0 votes
Daniel Ebers Community Leader Apr 05, 2021

Hi @ChristopherChilds

maybe I am missing the advantages of Script Runner for doing this particular job - but have you had a look into workflow properties?
They also can be used to restrict which resolution is offered in a specific workflow:
https://confluence.atlassian.com/adminjiraserver087/workflow-properties-998872279.html

I seem to understand you have several transitions in a likely complex workflow but what Taranjeet says is true from my view also - the setting should only apply to transition screens leading to a done/close status.
So, you would have to evaluate if this alternative approach using workflow properties work better over the Behaviours implementation.

Regards,
Daniel

Hello, @ChristopherChilds this code is set on Behavior right? In this case, the code cannot be applied on the View screen as documented here 

One alternative can be to remove this to the Edit screen, which avoids this field to be edited on the View screen, and add a resolution screen on Closing transitions

Thanks for the update. Can you just clarify what you mean by "remove this to the Edit screen"? The project uses the same screen for Create, Edit and View

Hi, @ChristopherChilds just create a copy of the screen, remove the resolution field and associate the new screen with the Edit operation on Screen Scheme. This guide can help you do this task if you need it. 

Taranjeet Singh Community Leader Mar 25, 2021

I think what @Fabio Oliveira Silva means to say is that the new screen (without the Resolution field) should be associated to the Edit Issue operation in the Screen Schemes for all issue types in the project. This won't allow Resolution to be editable, even from the View issue screen. The Resolution will be displayed on View Issue screen though.

Also, as @Fabio Oliveira Silva suggested, you should keep the Resolution field editable only on transition screens leading to Done or Closed statuses.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

330 views 3 14
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you