How to make the values of one field depend on the selection made in another field?

Tabla de contenidos

For example, if you have a “Reason” field and another “Subreason” field and you want that once the reason is selected, in the subreason field only the options corresponding to the selected reason are shown.

You have two ways to configure it, we explain them below.

Filter by the parent value indicated in the dictionary

For this option you will need:

Two selection or choice fields

In your form, create two “Choice” fields. The “parent” field must be marked with subtype “Dictionary”, and the child field must be marked with subtype “Related metadata”.

See how to add fields to a form.

Two dictionaries

Basically, you will need two lists of options:

  • The parent dictionary or set of terms for the field that must be selected first. For the case of our example, the reason.
  • The dependent or child dictionary, with the terms that must be filtered according to the selection of the parent field. In this case, when creating this dictionary, the parent dictionary must be indicated.

Add the terms in the child dictionary

The terms in the child dictionary must have the “Parent term from” information filled in. That is, in “Parent term from” we must select the option with which these terms will be visible.

Let’s look at it with an example.

In the terms of the options of the subreason field that must be shown when the user selects the option “Complaint due to dissatisfaction with customer service”, this option must be indicated as the parent term.

For each term added to the child dictionary, the parent term must be completed.

When in the reason field “Complaint due to dissatisfaction with customer service” has been selected, the Subreason field should only show the 3 previous options.

Once the dictionaries have been created, do not forget to link them to the fields created in the previous step.

Create the relationship between the fields

The last step is to create the relationship between the fields, which in Athento is called Related Choices and which can be created in the back-end, from the Metadata types menu.

To create the relationship, a new Metadata types is added and Athento will ask you for the following information:

  • Trigger: Select the metadatatype of the parent field
  • Related: Select the metadatatype of the child field
  • Data: Select the child dictionary
  • Document type: Select the name of the form
  • Filter type: Choose the option Filter related by parent
  • Suffix: Does not apply for this case

Configuration by term values (Obsolete)

For this option you will need:

Two selection or choice fields

In your form, create two “Choice” fields. The “parent” field must be marked with subtype “Dictionary”, and the child field must be marked with subtype “Related metadata”.

See how to add fields to a form.

Two dictionaries

Basically, you will need two lists of options:

  • The parent dictionary or set of terms for the field that must be selected first. For the case of our example, the reason.
  • The dependent or child dictionary, with the terms that must be filtered according to the selection of the parent field.

You can create the parent dictionary like any other dictionary. See how to add dictionaries.

Values of the child dictionary

The values of the child dictionary must include the values of its parent option.

Let’s look at it with an example.

PARENT DICTIONARY OPTION

Value = 1

Label = Complaint due to dissatisfaction with customer service

OPTIONS IN THE DEPENDENT OR CHILD DICTIONARY

  • Value= 1 / Label= Due to the wait to be attended
  • Value=2 / Label= Due to defects in the product or service
  • Value= 3 / Label= Due to poor attention from an employee

When in the reason field “Complaint due to dissatisfaction with customer service” has been selected, the Subreason field should only show the 3 previous options.

To indicate which reason the three subreasons belong to, they must be created in the dictionary with the following structure.

  • Value = Parent value-Child value
  • Label = Parent value-Child label

Specifically, for the option “Due to defects in the product or service”, the term must be created like this:

  • Value = 1-2
  • Label = 1-Due to defects in the product or service

Once the dictionaries have been created, do not forget to link them to the fields created in the previous step.

Create the relationship between the fields

The last step is to create the relationship between the fields, which in Athento is called Related Choices and which can be created in the back-end, from the Metadata types menu.

To create the relationship, a new Metadata types is added and Athento will ask you for the following information:

  • Trigger: Select the metadatatype of the parent field
  • Related: Select the metadatatype of the child field
  • Data: Select the child dictionary
  • Document type: Select the name of the form
  • Filter type: Choose the option Filter related by value
  • Suffix: Write a hyphen here

Important: In case it is required to add a third-level related field “Grandchild”, it is necessary to indicate in the configuration parameters a suffix different from the one indicated for the child field.