I use this article to restrict resolutions by IssueType using Behaviour, but it doesn't work.
I change my parametres as the code bellow and when I do a test, still appear all resolutions,.
my script:
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.Resolution
if (getActionName() == "Close Issue") {
def constantsManager = ComponentAccessor.constantsManager
def allowedResolutions = constantsManager.resolutions.findAll {
it.name in ["Duplicated"]
}
getFieldById("Resolution").setFieldOptions(allowedResolutions)
}
Have you tried with getFieldById("resolution")? System field ids are generally all lowercase.
Or, correct your import and use the correct RESOLUTION (without quotes)
import static com.atlassian.jira.issue.IssueFieldConstants.RESOLUTION
getFieldById(RESOLUTION).setFieldOptions()
Hello Peter,
Thanks for your reply.
I already tried that, but it didn't worked.
I'm having some problems with behaviour scripts that it's working in another instances and in this partilary it's not for some reason.
I think maybe the problem is with my version.
Jira: 7.6.1
ScriptRunner: 5.2.2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then the next step is to output some logs.
Also, you have to convert your allowedResolutions into a Map object
import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.Resolution
log.debug "Behavior Test - actionName= ${getActionName()}"
if (getActionName() == "Close Issue") {
def constantsManager = ComponentAccessor.constantsManager
def allowedResolutions = constantsManager.resolutions.findAll {
it.name in ["Duplicated"]
}
log.debug "Behavior Test - allowedResolutions = $allowedResolutions"
def resolutionMap = allowedResolutions.collectEntries{[(it.id ): it.name
log.debug "Behavior Test - resolutionMap = $resolutionMap"
getFieldById("resolution").setFieldOptions(resolutionMap)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.