Dependent drop down lists in Record producer

yasserbouat
Tera Guru

Hello,

Can someone please help me to set up the following configuration : 

In record producer, I should have two drop down lists dependents : 
List 1 contains values (A - B - C - D - E)

If we select A, or C, or E, they dont have dependent choices

if we select B, another drop down displays (B1 - B2)
If we select D, another drop down choices display (D1 - D2) : 

yasserbouat_0-1741014447472.png


I created the virst list as variable (select box) and i filled the choices (A - B - C - D - E) : 

yasserbouat_1-1741014515968.png


But I didn't know how to add dependent choices on each choice !

Thanks,

4 REPLIES 4

Rohit  Singh
Mega Sage

Hi @yasserbouat ,

 

Please refer this : Dependent Select Box (Choice) Variables on Record Producers 

 

If my response helped, please mark it helpful and accept the solution so that it benefits future readers.

 

Regards,
Rohit

Sandeep Rajput
Tera Patron
Tera Patron

@yasserbouat In case of variables, you will not be able to define the dependent values. Instead you need to rely on onChange Client script triggering on the first variable to filter data for second variable.

 

Here is a sample.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue === '') {
    return;
  }

  // Clear existing options.
  g_form.clearValue('second_select_box');

  if (newValue == 'B') {
    g_form.addOption('second_select_box', 'B1');
    g_form.addOption('second_select_box', 'B2');
  } else if (newValue == 'D') {
    g_form.addOption('second_select_box', 'D1');
    g_form.addOption('second_select_box', 'D2');
  }

}

Hello @Sandeep Rajput 

Thanks for your reply,  can you please tell me how to call this script to fill the choices ?

@yasserbouat This onChange script will trigger on your first drop down which contains the values A,B,C,D.

 

For more information on onChange client script please refer to https://servicenowwithrunjay.com/onchange-client-script-in-servicenow/