Overview
Populate dropdown lists with data from fields within an array on your form. Map a hidden field to reference your array and display specific array data within the dropdown options.
Array Setup
Add Array to Form
To create a data source for your dropdown list, add an array control to your form canvas. This array will contain the data for your dropdown options. Define fields within the array to hold your data. Add 'Equipment ID' and 'Serial Number' fields to store the data points that will appear in your dropdown.
Dropdowns Require Arrays
Dropdowns in Mirata reference an entire array to populate their options, not single fields.
Add Fields to Array
To dynamically populate your dropdown list, add a dropdown control from the 'Selectors' category to your form. Link this dropdown to your array. In the 'create a new field or reference an existing field' prompt, uncheck 'Create a New Field' and select your array as the referenced field. Add a calculation to the dropdown's label property to specify which array field populates the dropdown options.
Adding a Hidden Index Field
Bring an integer field into the form and name it something like "selection index" and make sure that the field is hidden within the visibility properties.
After creating this field, navigate back to the dropdown control, locate the Control properties, and link the index field to the Selection field.
The hidden selection field is extremely important, because without this, values will not be able to be stored within the dropdown control.
Form Preview
Preview Form
Add some records to the list that the dropdown references. Make the values different in each record of the list so that when checking the dropdown, it can be confirmed that the dropdown control is correctly referencing the Label Field (Serial Number).
Observe Dropdown Options
After selecting the dropdown, it is clear that the two different values for Serial Number are available to be selected from the list. Select one of the dropdown values and ensure that the value is populating in the control. If it is not populating, go back to the hidden index field and make sure that it is linked to the dropdown control.