@Jamie Echlin _ScriptRunner - The Adaptavist Group_
I'm looking for javascript or another option (scriptrunner is installed), to allow filtering of custom field B based on custom field A values. I've tried Cascading selects and they don't work for me due to the multi select need on the second custom field.
Custom field B will filter based on the selection of A and allow a selection of multiple values.
A :
Can anyone suggest a method to pull this off, without installing another plugin than scriptrunner?
A and B are required
these are mocked up in html, not as custom fields yet.
If A:1 is selected, the user can select any combination of the A,B,C values from B.
If A:2 is selected, the user can select any combination of the D, E, F values from B.
etc..
Hi David,
The recommended approach via ScriptRunner would probably be to use Behaviours. You would want to set up a server-side script on the single-select field which restricts the multi-select field's options using setFieldOptions:
import com.atlassian.jira.component.ComponentAccessor
def singleSelect = getFieldById(fieldChanged)
def multiSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("CustomFieldB")
def msConfig = customField.getRelevantConfig(issueContext)
def msOptions = ComponentAccessor.optionsManager.getOptions(msConfig)
def filteredOptions = msOptions
switch (singleSelect.value) {
case "1":
filteredOptions = msOptions.findAll {it.value in ['A', 'B', 'C']}
break
case "2":
filteredOptions = msOptions.findAll {it.value in ['D', 'E', 'F']}
break
}
formField.setFieldOptions(filteredOptions)
Thanks! @Joanna Choules
I'm setting up the Behaviour.
I changed customfield.getRelevant... to multiSelect.getRelevant...
and put an actual custom field name in our jira instance in the getCustomFieldObjectByName("... call
Do I need to define formField as something?
I've tried switching it to multiSelect, but no avail there either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh yes, sorry, you need to add a line to define a separate FormField for the multi-select:
def formMultiSelect = getFieldByName("CustomFieldB")
and then call setFieldOptions on that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Hightower
It will be nice if you share your full code here.
I getting error on line "def multiSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Alarm")"
Thanks,
Amar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello everyone
The code source it's fonctiannally , but i have a problem beacause when a i change the value for case for example i'm select "1" and after i select "2" the list does not update.
Exist a function or other for fix this problem ?
For have a list updated when to change case
Thanks in advance :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to create a new cascading select field to replace your existing fields? I use it and it works great for route problems to the appropriate support teams in our office.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Michael Thompson with the Cascading select, I was limited to a single value selection in the second field.
I need to be able to select 1 option in first field, then 1 to many in the second field.
I haven't found a way to get Cascading selects to work for that goal yet.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh, I see. In that case this option will not cut it for you. Sorry!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.