Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Dependent choice values

vinod6
Tera Contributor

I have Field 2 dependent on Field 1.

Field 1:
A
B
C
D

Field 2:
Unknown
None
Empty
Populated

Can I have a choice on Field 2 show if any of the choices from Field 1 are selected? For example, I want Unknown to show if any of the choices are selected in Field 1. Or, I want Unknown to show if A, B or C is selected in Field 1. 
Can please provide a client script for this it is helpful. Thanks!

6 REPLIES 6

Sebastian R_
Kilo Sage

Hi @vinod6,

you can make the choice field dependent on another choice field. You can check out the OOTB example for incident.subcategory.

SebastianR__0-1764072189893.png

In the choice values set the "Dependent value" accordingly for the choice values

SebastianR__1-1764072237572.png

 

 

sangrulkaradvai
Kilo Guru

you can use onchange Clientscript of Field 1

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) return;

    g_form.clearOptions('field_2');

    // Show "Unknown" only for A, B, or C
    if (newValue == 'A' || newValue == 'B' || newValue == 'C') {
        g_form.addOption('field_2', 'unknown', 'Unknown');
    }

    // Add other options normally
    g_form.addOption('field_2', 'none', 'None');
    g_form.addOption('field_2', 'empty', 'Empty');
    g_form.addOption('field_2', 'populated', 'Populated');
}

 

 

Sarthak Kashyap
Mega Sage

Hi @vinod6 ,

 

You can take a reference from category and subcategory field in incident form

 

Subcategory is dependent on category so if we select any category subcategory field will show that options only

SarthakKashyap_0-1764072602237.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

Mohammed8
Tera Sage

Hi @vinod6 

 

Similar to Incident form category/subcategory fields config, I created two fields here: Field-1 and Field-2

Then to the dictionary of Field-1 , under choices Field-1 set like this:

 

Mohammed8_2-1764072652727.png

 

Now go to dictionary of Field-2 and make it dependent on Field-1 as shown below:

 

Mohammed8_8-1764073108701.png

 

Configure choices for field-2 as shown, you can tweak as per your use case further

 

Mohammed8_1-1764072619079.png

 

Here is the result for above configuration:

 

Mohammed8_5-1764072733074.pngMohammed8_6-1764072754901.png

Mohammed8_7-1764072773042.png

 

If you find this answer useful, mark it as solution accepted/helpful

 

Thanks and Regards,

Mohammed Zakir