The Choice list widget requires a datasource to fetch the choices while rendering the form. The choice API datasource allows the user to fetch the data from a third party system using an API and display it for user selection.
To configure an API to a choice list, the user needs to specify certain API configurations such as the API URL, its method (GET, POST, etc), basic authentication information and the field map in the form designer.
The Field Map
While mapping the API data values in the form, the mapper first requests a sample record from the API to analyze the response type and the keys received in the API response. It can be done using the ‘Get Samples’ button in the right top of the mapper.
Mapping Part I
Once the response structure and the keys are received, those keys need to be mapped to specify a unique ID field, a title field, and a subtitle field for the choice list.
The unique ID is the identifier of the record. Title is displayed as the main text in the list and subtitle as the subtext below the title, to help user understand the choices for an easy selection.
Mapping Part II
The third party API response may consist of another keys in addition to the id, title and subtitle; which you want to use in your Axonator form.
If the choice API also provides additional values such as ‘location’ or ‘number’ in the above example, the response keys can be mapped with the rest of the fields in your form. For the purpose of additional keys mapping, the textbox type fields in the form are also listed on the field mapper.
Once the extra keys are also mapped, the mapped fields from the form get the selected values auto populated on the choice selection.
For example, if the Customers list is fetched in the choice list using an API, and you need the customer’s address to be auto-populated in the ‘Address’ field in your form, you can map it in the Part II area of the mapper. When a customer is selected from the list, their address received from the API will be set as the value of the ‘Address’ field in your form.