How to hide questions based on specific selections
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 07:26 PM
Hi all,
I am creating a catalog item that has a select box with some choices (questions). For example lucky_hs and hifi_gs.
There is another select box right after the one above with specific choices (questions). I am trying to show certain questions in the second select box based off the selection in the first one? Is that possible? I cant seem to add a UI policy action to the variable questions, just the variable itself.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:27 PM
You can write a catalog client script and use the g_form.removeOption(). This will solve your query.
UI policies can help only in mandatory,visibility and read-only of the variable not to their options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:31 PM
g_form.removeOption()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 10:34 PM
Hello @reza1921 ,
You can create On Change Catalog Client Script on one variable for the catalog item and add the given script as shown in below snapshot -
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if(newValue == '1'){
alert(newValue);
g_form.clearOptions('field_b_depends_on_field_a');
g_form.addOption('field_b_depends_on_field_a','A','A');
g_form.addOption('field_b_depends_on_field_a','B','B');
} else if(newValue == '2'){
g_form.clearOptions('field_b_depends_on_field_a');
g_form.addOption('field_b_depends_on_field_a','A','A');
g_form.addOption('field_b_depends_on_field_a','C','C');
}
//Please replace the variable names and choices
}
I have tried it in my PDI and it is working for me.
If my answer solves your issue, please mark it as Accepted✔️ and Helpful t👍 based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 11:02 PM
Hi @reza1921
Below post could be helpful :
Instead of having static choices for the second select box, you can make use of g_form.addOption() and g_form.removeOption() method to add or remove the choices based on selection of the first select box in an On-Change Catalog Client Script.
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.