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)
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @ChristopherChilds, I also used the same code in behaviors for restricting resolutions. It worked fine with Jira-8. Now we upgraded to Jira-9 and it complains:
it.name in ["Won't Fix", "Incomplete", "Cannot Reproduce"] - is not existing any more
constantsManager.getResolutionObjects() - is no more available
Do you have any suggestions how to overcome this problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Thales Deutschland
Our team encountered the same challenge today, and the following code works for us:
More details about constantsManager class can be found here (you should change the Jira version in the URL to your Jira Software Version): https://docs.atlassian.com/software/jira/docs/api/9.4.12/com/atlassian/jira/config/ConstantsManager.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.