For example, if you have a "Motive" field and a "Submotive" field and you want that once the motive is selected, only the options corresponding to the selected motive are shown in the submotive field.
You will need several things, which are explained below.
Two fields of type selection or choice
In your form, create two fields of type "Choice". The "parent" field should be marked with subtype "internal dictionary", and the child field should be marked with subtype "Related metadata".
Basically, you will need two lists of options:
- The parent dictionary or set of terms of the field to be selected first. For the case of our example, the reason.
- The dependent or child dictionary, with the terms to 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.
The child dictionary must have a special structure.
Dictionary values child
The values of the child dictionary must include the values of its parent option.
Let's see it with an example.
PARENT DICTIONARY OPTION
Value = 1
Label = Complaint due to dissatisfaction with customer service
OPTIONS IN THE DICTIONARY DEPENDENT OR CHILD
- Value= 1 / Label= For waiting to be served
- Value= 2 / Label= For defects in the product or service
- Value= 3 / Label= For poor service by an employee
When "Customer service complaint" has been selected in the Reason field, the Sub-reason field should only show the 3 options above.
To indicate to which motive the three submotives belong, 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 "For defects in the product or service", the term should be created as follows:
- Value = 1-2
- Label = 1-For 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 can be created in the back-end, from the Metadata types menu.
To create the relationship, Athento will ask you for the following information:
- Trigger: Selects the parent field metadatatype
- Related: Selects the metadatatype of the child field
- Data: Selects the child dictionary
- Filter type: Choose the option Filter related by label
- Suffix: Write a script here
With these settings, your dependent field should now work.