Resource as Select Component Data Source
Additional information and design considerations when using a Resource as the Data Source for a Select Component.
Last updated
Additional information and design considerations when using a Resource as the Data Source for a Select Component.
Last updated
Using a Resource as the Data Source for the selectable choices in a Select Component is a common workflow. This permits, for example, user-defined data to be incorporated into the Select Component's choices. As the Resource is polled when the Form is rendered, the choices available in the Select Component can vary significantly between uses, which can significantly alter the data included in a Form submission.
When choosing to use a Resource as the Data Source for a Select Component, it is important to consider how Resource data is managed and what impact this has on Submission data. One important consideration to this end is the "Save as reference" option available in the Select Component settings.
To examine the impact of this option, consider the following Transport Request Form with a Driver Select Component that is populated from a Driver Resource.
The value chosen within the Select Component is stored in the Submission Data as expected:
As with the Nested Form component, enabling the "Save as reference" function affects the way edited Submissions are recorded. When "Save as reference" is enabled, editing the resource following a submission will update the data in the recorded submission:
After editing the resource, any submissions recorded while the Select component was configured to "Save as reference" will reflect the update:
Note that even though the data recorded was updated, and the Resource's "Updated" field reflects the time, the original submission's "Updated" time does not change.
In contrast, the Submission of the form where "Save as reference" is not configured will retain the same data:
It is important to consider that when using a Resource as the Data Source for a Select Component, multiple actors within the project may be editing the Resource at any time. If the Resource is configured with "Save as reference," it is possible for Submission data to change if the resource is edited any time after the Submission is recorded. When this effect is intended, it is important to factor this into the application as a whole, as cached versions of the Submission data may not reflect such updates. Be careful to account for all downstream considerations that may arise when Submission data is configured to change synchronously with the Resource field.
Additionally, it is important to remember that a Form may directly or indirectly affect a Resource used as a Data Source within itself. This can create unanticipated and unpredictable behavior. Ensure that all workflows within the application that may alter a Resource that is used as a Data Source are sufficiently decoupled from processes that rely on that Resource as an input.
The following diagrams illustrate the relationship between the Select Component, the Resource, and the Submission, and the way the "Save as reference" option affects this relationship.
In the first example, the Resource supplies selectable fields for the Select Component's drop down. When one of these is selected and the form is submitted, the Submission will record the selected value as it was stored in the Resource at the time of the submission.
In the next illustration, the Resource is modified, but "Save as reference" is not selected. As a result, only submissions made after the change will reflect the alteration.
In the final illustration, "Save as reference" is selected. As a result, the previously recorded submission will reflect the change to the Resource, even if no new submission is made.