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

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

Franklin Vaugn Feb 05, 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 Vaugn Feb 06, 2019

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

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar alert! An IT Admin's Guide to Securing Collaboration at Scale

Hello, Atlassian Community! My name is Dave Meyer and I'm a Principal Product Manager at Atlassian. I wanted to give this community a heads up about an upcoming Webinar that might be of interest...

110 views 2 7
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