API Data Sources
API Data Sources are data source endpoints that can be used whenever some dynamic data is needed in FlexiForms. In other words, they open some data on your database to the use of FlexiForms easily.
Last updated
API Data Sources are data source endpoints that can be used whenever some dynamic data is needed in FlexiForms. In other words, they open some data on your database to the use of FlexiForms easily.
Last updated
API Data Sources make your data easily accessible to FlexiForms. Essentially, it allows your data to be communicated to FlexiForms through API endpoints, which can be used for various purposes.
The most common way of utilizing API data sources are Dynamic Data Injection into Forms.
Imagine you need a drop down list of employees, which often changes and hence need to be dynamically injected into the list.
Here, the choices for employees are fetched from the client’s database using the API Data Source setting, which can be easily configured as shown.
Here is another example: The cities are fetched from a database, and when a city is selected, the suburbs of the selected city are automatically populated, all thanks to the API Data Source:
Let's see how the data source used to inject suburbs based on the selected city is defined:
The definition above tells us that
There is a table called "Suburbs" on the database (which can be accessed via the database connection text called "DefaultConnectionString" specified on the Application Configuration file)
The "name" column stores suburb names on the Suburbs table.
There is also city_name column on the Suburbs table, which represent the city the suburb is located in.
This API data source is now accessible via an automatically generated an Web API endpoint, which can be tested on the same data sources page.
Now we can connect suburb field in the form to this API endpoint using Design page, as follows:
FlexiForms can also use the API data source endpoints to verify whether the end-user is authorized. For example, we can allow only certain users to fill out the form by checking if their email is in your whitelist, as in the following verification:
This verification setting tells us that the answer of the verification_email question will be passed to employee_testimony_duplicate_check API data source.
API endpoints can be used to feed a form with previously filled-in data. For this, the feed type should be selected "Web API", and then the WEB API URL should refer to the URL of an API data source:
Note that Web Service Url of the field (a.k.a Web API) is specified as ?<api_key>=<api_value>
If the API data source has multiple parameters, the same count of values should be passed in the URL, and the values should be seperated with a comma, for example ?<api_key>=<api_value>