I want to use the Resolution field as a sub-Status field for all Statuses not just Resolved. I'm using the Initializer function to default and only allow one resolution menu item: "Screening Required" when a new issue is being created. The "Screening Required" menu item does show up as the only item for Resolution field but when the issues is created, the Resolution field shows up as "Unresolved". Any ideas?
This code is based on https://scriptrunner.adaptavist.com/latest/jira/recipes/behaviours/restricting-priority-and-resolution.html
import com.atlassian.jira.component.ComponentAccessor; import static com.atlassian.jira.issue.IssueFieldConstants.RESOLUTION import com.atlassian.jira.ComponentManager def issueId = formContents["id"] if (issueId == null ) { // no issue key so new issue being entered def resolutionField = getFieldById(RESOLUTION) def constantsManager = ComponentAccessor.getConstantsManager() def allowedResolutions = constantsManager.getResolutionObjects().findAll { it.name in ["Screening Required"] }.collectEntries { [(it.id): it.name] } resolutionField.setFieldOptions(allowedResolutions) }
Community moderators have prevented the ability to post new answers.
You do know that if you do this, ALL your issues will be resolved at all times? The internal reporting becomes pretty much useless?
Well... JIRA treats the resolution field as special, in a very binary way. You are better of doing this with a select list custom field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yep, shame we can't +1 comments ;-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I realize I technically can't use jql: "resolution = unresolved" by itself anymore and that I must qualify all my searches with both "status = xxxx and resolution = yyyy" etc but I'm OK with that. Is this special "very binary way" of handling Resolution going to shoot me in the foot? Does that include not being able to default the Resolution field in the Create action?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can default the resolution on the screen. What we're getting at is that your issues will all be resolved at creation time. JIRA will treat them as closed in all the hard-coded reports you can't change. Some gadgets will be useless (created vs resolved is an obvious one). Agile REALLY won't work if you have it. Portfolio will report all your projects as completed all the time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Good points -- rethink time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have done what you're talking about with a simple select list field... worked ok.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Everything is simple but I'm an old C/Perl/bash hacker. My simple select list field isn't looking so simple. I created a new custom field: subStatus and populated it with some of the menu items matching the Resolution field. This behaviour initializer script will enable two of the menu items as a test but in the end, I'm still seeing all the menu items. {code} package com.onresolve.jira.groovy.user import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager public class ScriptSample extends FieldBehaviours { public void coriantInitsubStatusField () { CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); def issueId = formContents["id"] if (issueId == null ) { // creating new issue so hide subStatus and set it in the post-function for the Create action subStatusField.setHidden(true) } else { // existing issue Resolution defined based on Status def subStatusField = getFieldByName("subStatus") def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(issueId as Long) def currStatus = issue.status.name List filteredSubStatuses = ["Screened", "Under Analysis"] Map allowedOptions = new HashMap(); def sSObj = customFieldManager.getCustomFieldObjectByName('subStatus') for (def anOption:sSObj.getOptions(null, sSObj.getRelevantConfig(issue), null)) { if (filteredSubStatuses.contains(anOption.getValue())) { allowedOptions.put(anOption.getOptionId(), anOption.getValue()) } } for (def aKey: allowedOptions.keySet()) log.warn "<<BW>> ID = " + aKey + ", NAME = " + allowedOptions.get(aKey) subStatusField.setFieldOptions(allowedOptions) } } } {code} The logs: 2015-09-16 18:05:37,233 http-bio-8080-exec-12 WARN SwMgrA 1085x17510x1 avxjhg 192.168.109.121 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [jira.groovy.user.FieldBehaviours] <<BW>> ID = 10201, NAME = Screened 2015-09-16 18:05:37,233 http-bio-8080-exec-12 WARN SwMgrA 1085x17510x1 avxjhg 192.168.109.121 /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/validators.json [jira.groovy.user.FieldBehaviours] <<BW>> ID = 10202, NAME = Under Analysis More help would be appreciated. Thanks Brent
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Couple of problems... in the "if (issueId == null)" bit you haven't declared or initialised subStatusField, although you have done in the "else" block". Just move the declaration above the "if". Then log.warn the value of substatus field. It needs to be exact name and case, ie if your field is really called "Sub-status" it should be that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got it working using a separate "subStatus" custom field. Thanks Jamie and Nic for your help
package com.onresolve.jira.groovy.user import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.CustomFieldManager public class ScriptSample extends FieldBehaviours { public void coriantInitsubStatusField () { CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); def issueId = formContents["id"] def subStatusField = getFieldByName("subStatus") if (issueId == null ) { // creating new issue so hide subStatus and set it in the post-function for the Create action subStatusField.setHidden(true) } else { // existing issue Resolution defined based on Status def issue = ComponentManager.getInstance().getIssueManager().getIssueObject(issueId as Long) List filteredSubStatuses = ["Screened", "Under Analysis"] Map allowedOptions = [:] def sSObj = customFieldManager.getCustomFieldObjectByName('subStatus') for (def anOption:sSObj.getOptions(null, sSObj.getRelevantConfig(issue), null)) { if (filteredSubStatuses.contains(anOption.getValue())) { def anID = anOption.getOptionId() as String allowedOptions.put (anID, (anOption.getValue())) } } subStatusField.setFieldOptions(allowedOptions) } } }
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.