Auto-Generated Default Values
Imagine you need an auto-generated serial number for each form entry. You want this number to be displayed on the form so that the user can take a note of it. The logic behind the generation of the number may vary but it should be served by an API point. To sepecify that the default value for a field should come from an API end point, use "[api]" prefix for the default value of a field. For example a field with the default value of "[api]https://exampleAPI.com/retrieveSerialNumber" will be given an intiail value by the system that calls the API endpoint https://exampleAPI.com/retrieveSerialNumber. Usually auto-generated values are preferred to be read only as well. Json code for such a field is as follows:
{
"type": "text",
"name": "serial_number",
"defaultValue": "[api]https://flexiformstest.azurewebsites.net/api/crush_form_serial_number/?xdddddddP",
"readOnly": true
}The example question above also reveals that we can use API data sources for the API endpoint. We have defined an Stored Procedure type API data source that talks to a database process to retrieve the serial number. Then we use athe access URL of this data source as the default value for the question with "[api]" prefix. Whenever this form is loaded, this serial number is used as default for the question.
Last updated