How to hide field choices based on the other field choice selected in interaction form?
- 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:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:27 PM
Hi @Deepika61 ,
Write an onChange Client script on case table on 'Case type' field. Try the below code in your script and make changes as suggested in code (replace field name and transmitted options accordingly) :
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var transmittedOptions = ["abc", "def", "channel", "calls", "hij"]; //comma separated list of transmitted field option
if (g_form.getValue("case_type") == "support") {
transmittedOptions.forEach(function(opt) {
if (opt == "channel")
return;
if (opt == "calls")
return;
g_form.removeOption("transmitted_field_name", opt);
});
} else {
g_form.removeOption("transmitted_field_name", "calls");
g_form.removeOption("transmitted_field_name", "channel");
}
}
I hope this helps.
Regards,
Kamlesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 01:15 AM - edited 11-16-2022 01:16 AM
Hi Kamlesh,
Thanks for the response, Actually i have written client script for this, it works fine but it not clear the options
Means, if i select case type as support, it shows those two others choices along with all choices, and change to othe case type , it won't shows those two, its good, but the problem is when i select back to case type support, then it shows as privious one only, does not shows the other two choices
Please help me achieve this, please see the attachment for the script
Thanks
Deepika
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 01:44 AM
Hi @Deepika61 ,
Script that you used may not be sufficient as with change of selection you will need to clear the option and repopulate all of the options. Please use the below script, and let me know if this work for you :
function 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();
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();
transmittedOptions.forEach(function(opt) {
if (opt == "channel")
g_form.removeOption("transmitted_field_name", opt.value);
if (opt == "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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 02:06 AM
Hi Kamlesh,
Thanks for the code, but it wont works for me, with is , it actually doesnot shows any choices for case type support and shows all the choices for other case types
Thanks
Deepika