Use Form Data Model (FDM) 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 (FDM) that you can use as schema in various Adaptive Forms workflows. It requires configuring data sources and creating Form Data Model (FDM) based on data model objects and services available in data sources. For more information, see the following:

A Form Data Model (FDM) 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 (FDM). Do the following to use a Form Data Model (FDM) 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 model (FDM) 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 (FDM). Expand Form Data Model Definitions drop-down. It lists all data model objects in the specified form data model (FDM). 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 (FDM) 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 (FDM). 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 (FDM). 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 (FDM), 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 (FDM). 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 (FDM) and a Document of Record (DoR) to the data source. For information about form data model (FDM), 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 (FDM).

  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 (FDM). 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 (FDM).

  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 (FDM), you can create rules to invoke services configured in the form data model (FDM). The Invoke Services operation in a rule lists all available services in the Form Data Model (FDM) 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 (FDM) 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 (FDM) 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 (FDM). By default, the value is /content/dams/formsanddocuments-fdm/(.*) which includes all the Form Data Model (FDM). You can also specify the path for a specific Form Data Model (FDM).
  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 (FDM) 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