Multiple dependent fields by list value selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 02:47 AM
Hey guys,
I had a requirement, where from a drop down list, depending on the selected value, to show different fields. In general its easy enough with UI policy. But this is not working very good when you are to select again from the drop down - when you have many fields in the form the old field stays visible. So, if subcategory is dependent on incident type, and the tabs (plus fields) are dependent on the subcategory, it wont work really good. Especially if you select another subcategory - the tabs are going mad.
So what turned out to work just fine with very little code is using ternary operations in client on change script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue ){
(newValue.toLowerCase() == "unlawful") ? g_form.setSectionDisplay("unlawful", true) : g_form.setSectionDisplay("unlawful", false);
(newValue.toLowerCase() == "vulnerability") ? g_form.setSectionDisplay("vulnerability", true) : g_form.setSectionDisplay("vulnerability", false);
}
Hope this will help someone
Cheers,
Joro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 04:27 AM
Additionally, this will "hide" and the fields that are part of the tab.
Cheers,
Joro