Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

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

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

Hi Franklin - what was the workaround?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

104 views 1 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