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

Attempting to hide options in a select list based off of what is selected in another select list

I have a list of apps that can be selected in a multi-select field, and based off of those selections I wanted to display relevant fields in a separate multi-select field.  I was following along with the following post: https://community.atlassian.com/t5/Adaptavist-questions/ScriptRunner-Behaviours-change-select-list-based-on-customfield/qaq-p/788924 and made a good amount of progress, however I got stuck towards the end of the thread. Right now, I can see the behaviour attempting to run in my logs, however the functionality isn't working at all. I started receiving this error in my log after adding the very last line to set the fieldOptions to allowedOptions:  

 

Cannot resolve which method to invoke for [null] due to overlapping prototypes between:
[interface java.lang.Iterable]
[interface java.util.Map]
at Script1.run(Script1.groovy:67)

 

Worth noting that allowedOptions is evaluating to null, even though I am selecting an option in the affectedApp custom field of the Create Issue screen

Below is my code :

import com.atlassian.jira.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.customfields.*
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl

import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours


def allowedOptions = null
def optionsManager = ComponentAccessor.getOptionsManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def affectedAppField = getFieldByName("OutageAffectedApp")
def affectedAppValue = affectedAppField.getValue()
def affectedFunctionField = getFieldByName("OutageAffectedFunctionality")

def affectedFunctionCF = customFieldManager.getCustomFieldObjectByName("OutageAffectedFunctionality")

def config = affectedFunctionCF.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

log.warn("Value set to " + affectedAppValue)
log.warn("Config set to " + config)
log.warn("Options set to " + options)

if (affectedAppValue.toString() == "App1")
{
allowedOptions = affectedFunctionField.setFieldOptions(options.findAll {
it.value in ["Option1" , "Option2", "Option3"]
})
}
else if (affectedAppValue.toString() == "App2")
{
allowedOptions = affectedFunctionField.setFieldOptions(options.findAll {
it.value in ["Option4", "Option5", "Option6"]
})
}
else if (affectedAppValue.toString() == "App3")
{
allowedOptions = affectedFunctionField.setFieldOptions(options.findAll {
it.value in ["Option7", "Option8", "Option9"]
})
}

log.warn("Allowed Options evaluates to " + allowedOptions)
affectedFunctionField.setFieldOptions(allowedOptions)

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Comparison between Zephyr & Xray

I am sharing this article with both Zephyr and Xray information and everything should be in one place. It will be easy to know when selecting Zephyr or Xray. Zephyr and Xray are both Jira plug-ins u...

180 views 1 5
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