Use form data model
AEM Forms data integration lets you use disparate backend data sources to create a form data model that you can use as schema in various adaptive forms and interactive communications workflows. It requires configuring data sources and creating form data model based on data model objects and services available in data sources. For more information, see the following:
A form data model is an extension of JSON schema that you can use to:
Create adaptive forms and fragments
You can create adaptive forms and adaptive form fragments based on a form data model. Do the following to use a form data model when creating an adaptive form or adaptive form fragment:
- In Form Model tab on Add Properties screen, select Form Data Model in the Select From drop-down list.
- Tap to expand Select Form Data Model . All available form data models are listed.Select a from data model.
- ( Adaptive form fragments only ) You can create an adaptive form fragment based on only one data model object in a form data model. Expand Form Data Model Definitions drop-down. It lists all data model objects in the specified form data model. Select a data model object from the list.
Once the adaptive form or adaptive form fragment based on a form data model is created, form data model objects appear in the Data Model Objects tab of the Content browser in adaptive form editor.
For an adaptive form fragment, only the data model object selected at the time of authoring and its associated data model objects appear in the Data Model Objects tab.
You can drag-drop data model objects onto the adaptive form or fragment to add form fields. The added form fields retain the metadata properties and binding with data model object properties. The binding ensures that the field values are updated in the corresponding data sources on form submission and prefilled when the form is rendered.
Create interactive communications
You can create an interactive communication based on a form data model that you can use to prefill interactive communication with data from configured data sources. In addition, the building blocks of an interactive communication, such as text, list, and condition document fragments can be based on a form data model.
You can choose a form data model when creating an interactive communication or a document fragment. The following image shows the General tab of the Create Interactive Communication dialog.
General tab of Create Interactive Communication dialog
For more information, see:
Preview with sample data
Form data model editor allows you to generate and edit sample data for data model objects in the form data model. You can use this data to preview and test interactive communications and adaptive forms. You must generate the sample data before previewing as described in Work with form data model .
To preview an interactive communication with sample form data model data:
- On AEM author instance, navigate to Forms > Forms & Documents .
- Select an interactive communication and tap Preview in the toolbar to select Web Channel , Print Channel , or Both Channels to preview the interactive communication.
- In the Preview # dialog, ensure that Test Data of Form Data Model is selected and tap Preview .
The interactive communication opens with prefilled sample data.
Similarly, to preview an adaptive form with sample data, open the adaptive adaptive form in author mode and tap Preview .
Prefill using form data model service
AEM Forms provides out-of-the-box Form Data Model Prefill Service that you can enable for adaptive forms and interactive communications based on form data model. The prefill service queries data sources for data model objects in the adaptive form and interactive communication and accordingly prefills data while rendering the form or the communication.
To enable the Form Data Model Prefill Service for an adaptive form, open the Adaptive Form Container properties and select Form Data Model Prefill service from the Prefill Service drop-down in the Basic accordion. Then, save the properties.
To configure form data model prefill service in an interactive communication, you can select Form Data Model Prefill Service in the Prefill Service drop-down while creating it or later by modifying the properties.
Edit Properties dialog for an interactive communication
Write submitted adaptive form data into data sources
When a user submits a form based on a form data model, you can configure the form to write submitted data for a data model object to its data sources. To achieve this use case, AEM Forms provide Form Data Model submit action , available out-of-the-box only for adaptive forms based on a form data model. It writes submitted data for a data model object in its data source.
To configure the Form Data Model submit action, open Adaptive Form Container properties and select Submit using Form Data Model from the Submit Action drop-down under the Submission accordion. Then, browse and select a data model object from the Name of the data model object to submit drop-down. Save the properties.
On form submission, data for the configured data model object is written to the respective data source.
You can also submit form attachments to a data source using binary data model object property. Do the following to submit attachments to a JDBC data source:
- Add a data model object that includes a binary property to the form data model.
- In the adaptive form, drag-drop the File Attachment component from the Components browser onto the adaptive form.
- Tap to select the added component and tap to open the Properties browser for the component.
- In the Bind Reference field, tap and navigate to select the binary property you added in the form data model. Configure other properties, as appropriate.Tap to save the properties. The attachment field is now bound to the binary property of the form data model.
- In the Submission section of the Adaptive Form Container properties, enable Submit Form Attachments . It submits the attachment in the binary property field to the data source on form submission.
Invoke services in adaptive forms using rules
In an adaptive form based on a form data model, you can create rules to invoke services configured in the form data model. The Invoke Services operation in a rule lists all available services in the form data model and allows you to select input and output fields for the service. You can also use the Set Value rule type to invoke a form data model service and set the value of a field to the output returned by the service.
For example, the following rule invokes a get service that takes Employee Id as input and the values returned are populated in the corresponding Dependent Id, Last Name, First Name, and Gender fields in the form.