The CreatorCon Call for Content is officially open! Get started here.

Multiple dependent fields by list value selection

JK1
Giga Expert

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.

find_real_file.png

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

1 REPLY 1

JK1
Giga Expert

Additionally, this will "hide" and the fields that are part of the tab.



Cheers,



Joro