- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 04:46 AM
I have a scenario like this.
Choice List 1 -> Outlook, Teams, etc
Choice List 2 (for outlook) -> choice1, choice2
Choice List 3 (for Teams) -> choiceA, choice B
When I select the different choices within the first level of choice list, e.g. If i switch between choice1 and choice2, the questions appear and hide the way they shoudl
When I select different choices on the first level of choice list, e.g. If I switch between Outlook and Team, then the questions from the previous selection do not disappear.
will I need to write a onChange client script and reload the form when election from first level of choice list changes?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 08:33 PM
Have a look on the below example, you might be able to figure out the issue :
1. I have two variables, one for Tools with choices as Outlook and Teams and another for functionalities being offered by these tools where we will populate the choices dynamically based on the selection of tool.
2. To populate the functionality choices, I have an On-Change Catalog Client Script being configured which will populate the choices based on change of tool. Observe that I am clearing the field options each time before populating the choices :
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearOptions('function');
if(newValue == 'outlook'){
g_form.addOption('function','email','Email');
g_form.addOption('function','meeting','Meeting');
}
else if(newValue == 'teams'){
g_form.addOption('function','call','Call');
g_form.addOption('function','chat','Chat');
}
}
Result :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 05:05 AM
Hi @Saquib Mohammed ,
Yes, you can make use of onChange client script to control visibility of questions.
You need to clear the choice field before hiding it. If it is mandatory field make it non-mandatory before hiding it.
Please mark my answer helpful and accept as a solution if it helped 👍✔️
Kavita Bhojane
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 05:16 AM
Hi Saquib,
These are a bit tedious to code,
But what I do is, on change of the field I first clear the dependent field altogether and then add what I want.
the g_form.clearOptions('<field name>') is what you are missing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 08:57 AM
Hi Anurag
I am not looking at removing the choice options. That part is working fine. I am looking to remove the questions when top level choice value changes.
I was thinking of using onChange script with location.reload() method on the top level choice list variable. But it doesnt seem to work. Do you have any insight into that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2024 09:01 AM
If you need to remove a question then you can just hide the question
g_form.setDisplay('<field name>', true);
Why do you need to reload the form?