How to hide field choices based on the other field choice selected in interaction form?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:35 PM
Hi All,
Actually i have a requirement that in interaction for we have two choice fields 'case type' and 'Transmitted' , So in that if case type is support then in the Transmitted field need to display two choices(channel, calls) , for ther case types , that two choices(Channel, calls) need to hide?
Please help me to achieve this?
Thanks
Deepika
Labels:
- Labels:
-
Customer Service Management
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 02:20 AM
I saw one small mistake, I have rectified that in below code. Also make sure you are replacing all the 'name' and 'value' attribute of objects in array properly
unction onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
/*In the below array of objects name is the display name of option and value is backend name of option*/
var transmittedOptions = [{
"name": "ABC",
"value": "abc"
}, {
"name": "Def",
"value": "def"
}, {
"name": "Channel",
"value": "channel"
}, {
"name": "Hij",
"value": "hij"
}, {
"name": "Calls",
"value": "calls"
}]; //comma separated list of objects of transmitted field option
if (g_form.getValue("case_type") == "support") {
g_form.clearOptions("transmitted_field_name");
transmittedOptions.forEach(function(opt) {
if (opt.value == "channel")
g_form.addOption("transmitted_field_name", opt.value, opt.name);
if (opt.value == "calls")
g_form.addOption("transmitted_field_name", opt.value, opt.name);
g_form.removeOption("transmitted_field_name", opt.value);
});
} else {
g_form.clearOptions("transmitted_field_name");
transmittedOptions.forEach(function(opt) {
if (opt.value == "channel") // use proper backend name of your option, I have used 'channel'
g_form.removeOption("transmitted_field_name", opt.value);
if (opt.value == "calls") // use proper backend name of your option, I have used 'calls'
g_form.removeOption("transmitted_field_name", opt.value);
g_form.addOption("transmitted_field_name", opt.value,opt.name);
});
}
}
I hope this helps.
Regards,
Kamlesh