Using Form Data Model To Post Binary Data
Starting with AEM Forms 6.4, we now have the ability to invoke Form Data Model Service as a step in AEM Workflow. This article will walk you through a sample use case for posting Document of Record using Form Data Model Service.
The use case is as follows:
- A user fills and submits Adaptive Form.
- The adaptive form is configured to generate Document Of Record.
- On submission of this adaptive forms, AEM Workflow is triggered which will use the invoke Form Data Model Service to POST the Document Of Record to AEM DAM.
Form Data Model Tab - Properties
In the Service Input tab we map the following
- file(The Binary Object that needs to be stored) with DOR.pdf property relative to payload. What that means is when the Adaptive Form is submitted, the Document Of Record that is generated will be stored in a file called DOR.pdf relative to the workflow payload. Make sure this DOR.pdf is the same that you provide when configuring the Adaptive Form's submission property.
- fileName - This is the name by which the binary object will be stored in DAM. So you want this property to be dynamically generated, so that each fileName would be unique per submission. For this purpose we have used the process step in the workflow to create metadata property called filename and set its value to combination of Member Name and Account Number of the person submitting the form. For example if the member name of the person is John Jacobs and his account number is 9846, the file name would be John Jacobs_9846.pdf
Trouble Shooting Tips - If for some reason the DOR.pdf is not created in DAM, reset the data source authentication settings by clicking here . These are the AEM authentication settings, which by default is admin/admin.
To test this capability on your server, please follow the steps mentioned below:
- Download and deploy the setvalue bundle .This custom OSGI bundle is used to create metadata property and set its value from the submitted form data.
- Import the assets associated with this article into AEM using the package manager.You will get the following
- Workflow Model
- Adaptive Form configured to submit to the AEM Workflow
- Data source configured to use PostToDam.JSON file
- Form Data Model which uses the Data Source
- Point your browser to open the Adaptive Form
- Fill the form and submit.
- Check the Assets application if the Document of Record is created and stored.
Swagger File used in creating the data source is available for your reference