JIRA Behaviours - how to use setFieldOptions for cascading select field?

Adam Yerkman November 11, 2014

I'm trying to set up functionality similar to https://jamieechlin.atlassian.net/wiki/display/JBHV/Miscellaneous+Behaviours+Examples#MiscellaneousBehavioursExamples-Addorremoveoptionstosingleormulti-selectfields but instead of a single or multi select field, I'm trying to do so with a cascading select field. The below code will populate the first dropdown of a cascading select field, but none of the values from the second dropdown show up. Does anyone have any information on how the data needs to be formatted in order to get the setFieldOptions method to work for both dropdowns in a cascading select field?

 

FormField functionalArea = getFieldByName("Functional Area")
def ops = ["-1":"None"]
ops.put("50632","508 Compliance Testing")
ops.put("50620","Activity Tracking")
functionalArea.setFieldOptions(ops)

3 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 12, 2014

I don't remember if cascading selects are properly supported or not, but your example code is what you'd use for setting a single select. For cascading selects the values should themselves be option ID->value maps.

Adam Yerkman November 14, 2014

I was thinking about that too. But doing this seems to not adjust the values seen on the screen at all. No errors in the log either. Then I started thinking again, wouldn't the second value in the map need to be a list of maps in order to handle multiple values in the second dropdown? I implemented the below map to setFormValues() with, and again, it doesn't appear to adjust the values either with no errors in the log. I enabled debugging and it returns a map. def ops = [:] ops.put(["-1":"None"],["-1":"None"]) ops.put(["50632":"508 Compliance Testing"],["-1":"None"]) ops.put(["50620":"Activity Tracking"],[["-1","None"],["50621":"To Do List"],["50628":"Work Activity Log"]]) /rest/com.onresolve.jira.plugin.Behaviours/1.0/behaviours/runvalidator.json [onresolve.jira.groovy.BehaviourManagerImpl] Returning map: [customfield_10081:[fieldOptions:[[-1:None]:[-1:None], [50632:508 Compliance Testing]:[-1:None], [50620:Activity Tracking]:[[-1, None], [50621:To Do List], [50628:Work Activity Log]]], fieldType:com.atlassian.jira.plugin.system.customfieldtypes:cascadingselect, displayName:Functional Area]] Is there any way you could determine if cascading selects are properly supported? I'm starting to get the feeling they aren't based on my inability get it to work with all the different data types I've tried to put in here.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 14, 2014

I do not have a functional test for cascading selects, which I'm afraid suggests to me that they are not implemented. There is also https://jamieechlin.atlassian.net/browse/JBHV-202.

Adam Yerkman November 17, 2014

Alright. I think I'll just mark this as an accepted answer because functionality not implemented is what it is. I'm sure if you do implement it in the future, you will put it in the release notes for the plugin. Thanks for looking into this and thanks for making a great plugin for JIRA.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 17, 2014

thanks for your understanding.

MohammadA January 6, 2015

Adam Yerkman - did you find any alternative to do this?

Adam Yerkman January 7, 2015

I haven't found an alternative yet. I told the group that requested it from me that it wasn't possible to my knowledge, and I will investigate any solutions that might implement this functionality.

MohammadA January 7, 2015

I did a work-around. I use two select list that act as this cascading select list. Probably u can do that :)

0 votes
Carol Jones February 12, 2018
Carlos David October 15, 2019

Don't think so:

 

SRJIRA-2125 is about the ability to choose values in the form - setFormValue() i.e. the values have to already be present in the select list in order to be set.

 

The question is about setting the *list of options* in a cascading select list i.e. using setFieldOptions on a cascading select

Irfan Azeez March 7, 2023

I am still not able to set the child option with setFieldOptions(), is there a solution available yet?

0 votes
Arianna Fabbri November 14, 2016

Hi @Adam Yerkman, have you found a solution for this?

Thank you in advance

Suggest an answer

Log in or Sign up to answer