A Submit Action is triggered when a user clicks the Submit button on an Adaptive Form. Adaptive Forms provide some Submit Actions out of the box. The Submit Actions available out of the box are:
You can also extend the default Submit Actions to create your own Submit Action.
You can configure a Submit Action in the Submission section of the Adaptive Form Container properties, in the sidebar.
Use the Submit to REST Endpoint action to post the submitted data to a rest URL. The URL can be of an internal (the server on which the form is rendered) or an external server.
To post data to an internal server, provide path of the resource. The data is posted the path of the resource. For example, /content/restEndPoint. For such post requests, the authentication information of the submit request is used.
To post data to an external server, provide a URL. The format of the URL is https://host:port/path_to_rest_end_point
. Ensure that you configure the path to handle the POST request anonymously.
In the example above, user entered information in textbox
is captured using parameter param1
. Syntax to post data captured using param1
is:
String data=request.getParameter("param1");
Similarly, parameters that you use for posting XML data and attachments are dataXml
and attachments
.
For example, you use these two parameters in your script to parse data to a rest end point. You use the following syntax to store and parse the data:
String data=request.getParameter("dataXml");
String att=request.getParameter("attachments");
In this example, data
stores the XML data, and att
stores attachment data.
The Submit to REST endpoint Submit Action submits the data filled in the form to a configured confirmation page as part of the HTTP GET request. You can add the name of the fields to request. The format of the request is:
{fieldName}={request parameter name}
As shown in the image below, param1
and param2
are passed as parameters with values copied from the textbox and numericbox fields for the next action.
You can also Enable POST request and provide a URL to post the request. To submit data to the AEM server hosting the form, use a relative path corresponding to the root path of the AEM server. For example, /content/forms/af/SampleForm.html
. To submit data to any other server, use absolute path.
To pass the fields as parameters in a REST URL, all the fields must have different element names, even if the fields are placed on different panels.
You can use the Send Email Submit Action to send an email to one or more recipients on successful submission of the form. The email generated can contain form data in a predefined format. For example, in the following template, customer name, shipping address, name of the state, and zip code are retrieved from submitted form data.
```
Hi ${customer_Name},
The following is set as your deafult shipping address:
${customer_Name},
${customer_Shipping_Address},
${customer_State},
${customer_ZIPCode}
Regards,
WKND
```
You can also include attachments and a Document of Record (DoR) to the email. To enable Attach Document of Record option, configure the Adaptive Form to generate a Document of Record (DoR). You can enable the option to generate a Document of Record from Adaptive Form properties.
The Submit using Form Data Model Submit Action writes submitted Adaptive Form data for the specified data model object in a Form Data Model to its data source. When configuring the Submit Action, you can choose a data model object whose submitted data you want to write back to its 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.
The Invoke an AEM Workflow Submit Action associates an Adaptive Form with an AEM Workflow. When a form is submitted, the associated workflow starts automatically on the Author instance. You can save the data file, attachments, and Document of Record to the payload location of the workflow or to a variable. If the workflow is marked for external data storage and configured for an external data storage, then only the variable option is available. You can select from the list of variables available for the workflow model. If the workflow is marked for external data storage at a later stage and not at the time of workflow creation, then ensure that the required variable configurations are in place.
The Submit Action places the following at the payload location of the workflow, or the variable if the workflow is marked for external data storage:
Data file: It contains data submitted to the Adaptive Form. You can use the Data File Path option to specify the name of the file and path of file relative to the payload. For example, the /addresschange/data.xml
path creates a folder named addresschange
and places it relative to payload. You can also specify only data.xml
to send only submitted data without creating a folder hierarchy. If the workflow is marked for external data storage, use the variable option and select the variable from the list of variables available for the workflow model.
Attachments: You can use the Attachment Path option to specify the folder name to store the attachments uploaded to the Adaptive Form. The folder is created relative to the payload. If the workflow is marked for external data storage, use the variable option and select the variable from the list of variables available for the workflow model.
Document of Record: It contains the Document of Record generated for the Adaptive Form. You can use the Document of Record Path option to specify the name of the Document of Record file and path of file relative to the payload. For example, the /addresschange/DoR.pdf
path creates a folder named addresschange
relative to the payload and places the DoR.pdf
relative to payload. You can also specify only DoR.pdf
to save only Document of Record without creating a folder hierarchy. If the workflow is marked for external data storage, use the variable option and select the variable from the list of variables available for the workflow model.
Before using the Invoke an AEM Workflow Submit Action configure the following for the AEM DS settings service configuration:
Processing Server URL: The Processing Server is the server where the Forms or AEM Workflow is triggered. This can be same as the URL of the AEM author instance or another server.
Processing Server User Name: Workflow user’s username
Processing Server Password: Workflow user’s password
The Submit to SharePoint Submit Action connects an Adaptive Form with a Microsoft® SharePoint Storage. You can submit the form data file, attachments, or Document of Record to the connected Microsoft® Sharepoint Storage. To use the Submit to SharePoint Submit Action in an Adaptive Form:
To connect AEM Forms to your Microsoft® Sharepoint Storage:
Go to your AEM Forms Author instance > Tools > Cloud Services > Microsoft® SharePoint.
Once you select the Microsoft® SharePoint, you are redirected to SharePoint Browser.
Select a Configuration Container. The configuration is stored in the selected Configuration Container.
Click Create. The SharePoint configuration wizard appears.
Specify the Title, Client ID, Client Secret and OAuth URL. For information on how to retrieve Client ID, Client Secret, Tenant ID for OAuth URL, see Microsoft® Documentation.
Client ID
and Client Secret
of your app from the Microsoft® Azure portal.https://[author-instance]/libs/cq/sharepoint/content/configurations/wizard.html
. Replace [author-instance]
with the URL of your Author instance.offline_access
and Sites.Manage.All
to provide read/write permissions.https://login.microsoftonline.com/tenant-id/oauth2/v2.0/authorize
. Replace <tenant-id>
with the tenant-id
of your app from the Microsoft® Azure portal.The client secret field is mandatory or optional depends upon your Azure Active Directory application configuration. If your application is configured to use a client secret, it is mandatory to provide the client secret.
Click Connect. On a successful connection, the Connection Successful
message appears.
Now, select SharePoint Site > Document Library > SharePoint Folder, to save the data.
forms-ootb-storage-adaptive-forms-submission
is present at selected SharePoint Site.forms-ootb-storage-adaptive-forms-submission
, if not already present in the Documents
library of the selected SharePoint Site by clicking Create Folder.Now, you can use this SharePoint Sites configuration for the submit action in an Adaptive Form.
You can use the created SharePoint configuration in an Adaptive Form, to save data or generated Document of Record in a SharePoint folder. Perform the following steps to use a SharePoint storage configuration in an Adaptive Form as:
Create an Adaptive Form.
Select Submit Action as Submit to SharePoint.
Select the Storage Configuration, where you want to save your data.
Click Save to save the Submit settings.
When you submit the form, the data is saved in the specified Microsoft® Sharepoint Storage.
Folder structure to save data is /folder_name/form_name/year/month/date/submission_id/data
.
The Submit to OneDrive Submit Action connects an Adaptive Form with a Microsoft® OneDrive. You can submit the form data, file, attachments, or Document of Record to the connected Microsoft® OneDrive Storage. To use the Submit to OneDrive Submit Action in an Adaptive Form:
To connect AEM Forms to your Microsoft® OneDrive Storage:
Go to your AEM Forms Author instance > Tools > Cloud Services > Microsoft® OneDrive.
Once you select the Microsoft® OneDrive, you are redirected to OneDrive Browser.
Select a Configuration Container. The configuration is stored in the selected Configuration Container.
Click Create. The OneDrive configuration wizard appears.
Specify the Title, Client ID, Client Secret and OAuth URL. For information on how to retrieve Client ID, Client Secret, Tenant ID for OAuth URL, see Microsoft® Documentation.
Client ID
and Client Secret
of your app from the Microsoft® Azure portal.https://[author-instance]/libs/cq/onedrive/content/configurations/wizard.html
. Replace [author-instance]
with the URL of your Author instance.offline_access
and Files.ReadWrite.All
to provide read/write permissions.https://login.microsoftonline.com/tenant-id/oauth2/v2.0/authorize
. Replace <tenant-id>
with the tenant-id
of your app from the Microsoft® Azure portal.The client secret field is mandatory or optional depends upon your Azure Active Directory application configuration. If your application is configured to use a client secret, it is mandatory to provide the client secret.
Click Connect. On a successful connection, the Connection Successful
message appears.
Now, select OneDrive Container > [OneDrive Folder] to save the data.
forms-ootb-storage-adaptive-forms-submission
is present at OneDrive Container.forms-ootb-storage-adaptive-forms-submission
, if not already present by clicking Create Folder.Now, you can use this OneDrive storage configuration for the submit action in an Adaptive Form.
You can use the created OneDrive storage configuration in an Adaptive Form, to save data or generated Document of Record in a OneDrive folder. Perform the following steps to use OneDrive storage configuration in an Adaptive Form as:
Create an Adaptive Form.
Select Submit Action as Submit to OneDrive.
Select the Storage Configuration, where you want to save your data.
Click Save to save the Submit settings.
When you submit the form, the data is saved in the specified Microsoft® OneDrive Storage.
Folder structure to save data is /folder_name/form_name/year/month/date/submission_id/data
.
The Submit to Azure Blob Storage Submit Action connects an Adaptive Form with a Microsoft® Azure portal. You can submit the form data, file, attachments, or Document of Record to the connected Azure Storage containers. To use the Submit action for Azure Blob Storage:
To connect AEM Forms to your Azure Storage containers:
Go to your AEM Forms Author instance > Tools > Cloud Services > Azure Storage.
Once you select the Azure Storage, you are redirected to Azure Storage Browser.
Select a Configuration Container. The configuration is stored in the selected Configuration Container.
Click Create. The Create Azure Storage Configuration wizard appears.
Specify the Title, Azure Storage Account and Azure Access key.
Azure Storage Account
name and Azure Access key
from the Storage Accounts in the Microsoft® Azure portal.Click Save.
Now, you can use this Azure Storage container configuration for the submit action in an Adaptive Form.
You can use the created Azure Storage container configuration in an Adaptive Form, to save data or generated Document of Record in Azure Storage container. Perform the following steps to use Azure Storage container configuration in an Adaptive Form as:
Create an Adaptive Form.
Select Submit Action as Submit to Azure Blob Storage.
Select the Storage Configuration, where you want to save your data.
Click Save to save the Submit settings.
When you submit the form, the data is saved in the specified Azure Storage container configuration.
Folder structure to save data is /configuration_container/form_name/year/month/date/submission_id/data
.
To set values of a configuration, Generate OSGi Configurations using the AEM SDK, and deploy the configuration to your Cloud Service instance.
A Submit Action can use synchronous or asynchronous submission.
Synchronous submission: Traditionally, web forms are configured to submit synchronously. In a synchronous submission, when users submit a form, they are redirected to an acknowledgment page, a thank you page, or if there is submission failure, an error page. You can select the Use asynchronous submission option to redirect the users to a webpage or show a message on submission.
Asynchronous submission: Modern web experiences like single page applications are gaining popularity where the web page remains static while client-server interaction happens in the background. You can now provide this experience with Adaptive Forms by configuring asynchronous submission.
Typically, in any online data capture system, developers place someJavaScript validations on client side to enforce a few business rules. But in modern browsers, end users have way to bypass those validations and manually do submissions using various techniques, Such as Web Browser DevTools Console. Such techniques are also valid for Adaptive Forms. A forms developer can create various validation logics, but technically, end users can bypass those validation logics and submit invalid data to the server. Invalid data would break the business rules that a forms author has enforced.
The server-side revalidation feature provides the ability to also run the validations that an Adaptive Forms author has provided while designing an Adaptive Form on the server. It prevents any possible compromise of data submissions and business rules violations represented in terms of form validations.
All out of the box (OOTB) field validations of an Adaptive Form that are rerun at the server are:
Use the Revalidate on server under Adaptive Form Container in the sidebar to enable or disable server-side validation for the current form.
Enabling Server-Side Validation
If end-user bypass those validations and submit the forms, the server again performs the validation. If the validation fails at server end, then the submit transaction is stopped. The end user is presented with the original form again. The captured data and submitted data are presented to the user as an error.
Server-side validation validates the form model. You are recommended to create a separate client library for validations and not mix it with other things like HTML styling and DOM manipulation in the same client library.
At times, if there are complex validation rules, the exact validation script reside in custom functions and author calls these custom functions from field validation expression. To make this custom function library known and available while performing server-side validations, the form author can configure the name of AEM client library under the Basic tab of Adaptive Form Container properties as shown below.
Supporting Custom functions in Validation Expressions
Author can configure customJavaScript library per Adaptive Form. In the library, only keep the reusable functions, which have dependency on jquery and underscore.js third-party libraries.
As a part of AEM security and hardening guidelines, configure custom error pages such as 400.jsp, 404.jsp, and 500.jsp. These handlers are called, when on submitting a form 400, 404, or 500 errors appear. The handlers are also called when these error codes are triggered on the Publish node. You can also create JSP pages for other HTTP error codes.
When you prefill a form data model, or schema based Adaptive Form with XML or JSON data complaint to a schema that is data does not contain <afData>
, <afBoundData>
, and </afUnboundData>
tags, then the data of unbounded fields of the Adaptive Form is lost. The schema can be an XML schema, JSON schema, or a Form Data Model. Unbounded fields are Adaptive Form fields without the bindref
property.