You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
Is it possible to filter the shown values in a cascading select based on a single select selection?
for example
I have a field called Topic that is a single select with values 1, 2 and 3
I have a cascading select field called Product with parents:
A and child A1,B2,B3
B and child B1,B2,B3
C and child C1,C2,C3
I need to hide parent B and C when I select 1 from field Topic
When I select 2 from Topic I need to hide parents A and B
Thanks
Hi, Team if c1 is selected from the child I need to display a new selectlist field called Test select list, Please help me with a script or option.
For your requirement, you can try something like this:-
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
@BaseScript FieldBehaviours behaviours
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def sampleList = getFieldById(fieldChanged)
def sampleListValue = sampleList.value.toString()
def sampleCascade = getFieldByName('Sample Cascade')
def filteredCascadeField = customFieldManager.getCustomFieldObject(sampleCascade.fieldId)
def availableConfig = filteredCascadeField.getRelevantConfig(issueContext)
def listCascadeOptions = optionsManager.getOptions(availableConfig)
def childField = getFieldById("${sampleCascade.fieldId}:1")
def childList = customFieldManager.getCustomFieldObject(childField.fieldId)
def msConfig = childList.getRelevantConfig(issueContext)
def childOptions = optionsManager.getOptions(msConfig)
def availableOptions
if (sampleListValue == '1') {
availableOptions = listCascadeOptions.findAll {it.value in ['A'] }.collectEntries {[(it.optionId.toString()) : it.value] }
} else if (sampleListValue == '2') {
availableOptions = listCascadeOptions.findAll {it.value in ['B'] }.collectEntries {[(it.optionId.toString()) : it.value] }
} else if (sampleListValue == '3') {
availableOptions = listCascadeOptions.findAll {it.value in ['C'] }.collectEntries {[(it.optionId.toString()) : it.value] }
}
sampleCascade.setFieldOptions(availableOptions)
sampleCascade.setFormValue([availableOptions, childOptions.optionId])
Please note that the sample working above is not 100% exact to your environment. Hence, you will need to make the required modifications.
The code above is for a Server-Side Behaviour, i.e. for the Single Select list that you want to use to filter the Cascading List.
This Server-Side Behaviour filters the Sample Cascade field when the value from the Sample List field is selected.
Below is a print screen of the Behaviour configuration:-
Also, I include a few test print screens for your reference:-
1. When I select option 1 from the Sample List, the Sample Cascade list is filtered to only option A and its child list will only show the options A1, A2 and A3, as shown in the print screens below:-
2. When I select option 2 from the Sample List, the Sample Cascade list is filtered to only option B, and its child list will only show the options B1, B2 and B3 as shown in the print screens below:-
3. Lastly, when I select option 3 from the Sample List, the Sample Cascade list is filtered to only option C, and its child list will only show the options C1, C2 and C3, as shown in the print screens below:-
I hope this helps to solve your question. :)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Team,
If I select C1 from Child need a new select list field called Test to be enabled, Please help me with a Groovy script or by options.
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.