ScripRunner Behaviors are Not Working With MultiSelect Field on the Create Screen

Franklin February 5, 2019

I am trying to use Behaviors in conjunction with Project/Issue Type context--all the options are in one context with a project/issue type mapping. The goal is to turn off checkboxes in a multi-select field based on project mapping and issue type, but nothing we do seems to work on the Create screen. Once you click on a checkbox however the behavior works as expected, but, NOT when the page loads initially.

I have seen several examples of the code with slight syntactical variations posted across Jira newsgroups. I've tried them but they all produce the same result. Nothing will change the length of the multi-select field on the Create screen based on Issue Type.

But to reiterate, it does work on the Edit and View screens. Just not on the Create screen, unless that is you select one of the checkboxes. Then it works. Any help would be greatly appreciated. We are using Jira 7.10.x. I've tried setting the Field in the Behavior to both Fieldname and IssueType, but neither of those options worked either.

 

 Here's the server-side script snippet.

 

import com.atlassian.jira.component.ComponentAccessor

def cFManager = ComponentAccessor.getCustomFieldManager()
def oManager = ComponentAccessor.optionsManager
def envType = customFieldManager.getCustomFieldObject(getFieldChanged())
def config = envType.getRelevantConfig(getIssueContext())
def options = oManager.getOptions(config)
def selectcf = getFieldByName("FieldName")


if (getIssueContext().getIssueType().getName() == "Issue Type 1") {
def optionsMap = options.findAll {
it.value in ["VALUE1","VALUE2",] // list of options to show
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf.setFieldOptions(optionsMap)
}
else if (getIssueContext().getIssueType().getName() == "Issue Type 2")
{
def optionsMap = options.findAll {
it.value in ["VALUE3", "VALUE4"] // list of options to show.
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf.setFieldOptions(optionsMap)
}

 

1 answer

0 votes
Franklin February 6, 2019

Never mind. I figured out a workaround. Works just fine now. 

Manish Kumar April 22, 2020

Hi Franklin - what was the workaround?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events