Use Form Data Model use-form-data-model

Version
Article link
AEM 6.5
Click here
AEM as a Cloud Service
This article

data-integration

Experience Manager 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 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 create-af

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:

  1. In Form Model tab on Add Properties screen, select Form Data Model in the Select From drop-down list.

    create-af-1-1

  2. Select to expand Select Form Data Model. All available form data models are listed.

    Select a from data model.

    create-af-2-1

  3. (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.

    create-af-3

    Once the Adaptive Form or Adaptive Form Fragment based on a Form Data Model is created, Form Data Model objects appear in the Data Sources tab of the Content browser in Adaptive Form editor.

    note note
    NOTE
    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 Sources tab.

    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.

Preview with sample data preview-ic

Form Data Model editor lets you generate and edit sample data for data model objects in the form data model. You can use this data to preview and test Adaptive Forms. You must generate the sample data before previewing as described in Work with form data model.

To preview an Adaptive Form with sample data, open the Adaptive Form in author mode and select Preview.

Prefill using Form Data Model service prefill

Experience Manager Forms provides out-of-the-box Form Data Model Prefill Service that you can enable for Adaptive Forms based on form data model. The prefill service queries data sources for data model objects in the Adaptive Form 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.

prefill-service

Write submitted Adaptive Form data into data sources write-af

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, Experience Manager 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:

  1. Open the Content browser, and select the Guide Container component of your Adaptive Form.

  2. Click the Guide Container properties Guide properties icon. The Adaptive Form Container dialog box opens.

  3. Click the Submission tab.

  4. From the Submit Action drop-down list, select Submit using Form Data Model.

    Action configuration

  5. Specify the Data model to submit.

  6. Click Done

On form submission, data for the configured data model object is written to the respective data source. In addition, you can submit a form attachment using a Form Data Model and a Document of Record (DoR) to the data source. For information about form data model, see AEM Forms Data Integration.

NOTE
AEM as a Cloud Service offers various out of the box submit actions for handling form submissions. You can learn more about these options in the Adaptive Form Submit Action article.

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:

  1. Add a data model object that includes a binary property to the form data model.

  2. In the Adaptive Form, drag-drop the File Attachment component from the Components browser onto the Adaptive Form.

  3. Select to select the added component and select settings_icon to open the Properties browser for the component.

  4. In the Bind Reference field, select foldersearch_18 and navigate to select the binary property you added in the form data model. Configure other properties, as appropriate.

    Select check-button to save the properties. The attachment field is now bound to the binary property of the form data model.

  5. 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 invoke-services

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 lets you 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.

invoke-service

In addition, you can use the guidelib.dataIntegrationUtils.executeOperation API to write a JavaScript in the code editor for the rule editor.

Invoke a form data model using custom functions invoke-form-data-model-using-custom-functions

You can invoke a form data model from rule editor using custom functions. To invoke the form data model add a form data model to the allowlist. To add a form data model to an allowtlist:

  1. Go to Experience Manager web console at https://server:host/system/console/configMgr.
  2. Locate Adaptive Form-Level Whitelisting of Form Data Model for Service Invocation - Configuration Factory.
  3. Click plus icon icon to add the configuration…
  4. Add Content path pattern to specify the location of your Adaptive Forms. By default, the value is /content/forms/af/(.*) which includes all the Adaptive Forms. You can also specify the path for a specific Adaptive Form.
  5. Add Form Data Model path pattern to specify the location of form data model. By default, the value is /content/dams/formsanddocuments-fdm/(.*) which includes all the Form Data Model. You can also specify the path for a specific Form Data Model.
  6. Save the settings.

The added configuration is saved under the Adaptive Form-Level Whitelisting of Form Data Model for Service Invocation - Configuration Factory option.

NOTE
To invoke a form data model from the rule editor using custom functions through an AEM archetype project:
  1. Create a configuration file.
  2. Set properties of getContentPathPattern and getFormDataModelPathPattern.
  3. Deploy the project.
recommendation-more-help
fbcff2a9-b6fe-4574-b04a-21e75df764ab