This article will walk through the use case of storing and tagging the DoR generated by AEM Forms in AEM DAM. The tagging of the document is done based on the submitted form data.
A common ask from customers is to store and tag the Document of Record(DoR) generated by AEM Forms in AEM DAM. The tagging of the document needs to be based on the Adaptive Forms’ submitted data. For example, if the employment status in the submitted data is “Retired”, we want to tag the document with “Retired” tag and store the document in DAM.
The use case is as follows:
To satisfy this use case a custom process step was written. In this step we fetch the values of the appropriate data elements from the submitted data. We then construct the tag tile using this value. For example if the value of marital status element is “Single”, the tag title becomes **Peak:EmploymentStatus/Single. **Using the TagManager API , we find the tag and apply the tag to the DoR.
The following code snippet show you how to find the tag and apply the tag to the document.
Tag tagFound = tagManager.resolveByTitle(tagTitle+xmlElement.getTextContent()); //tagTitle is "Peak:EmploymentStatus/" and the xmlElement.getTextContent() will return the value Single. So the tag title becomes Peak:EmploymentStatus/Single. Once the tag is found we put the tag in array and apply the tags to the resource as shown below tagArray[i] = tagFound; tagManager.setTags(metadata, tagArray, true);
To get this sample working on your system,Please follow the steps listed below:
Download and deploy the setvalue bundle. This is the custom OSGI bundle which sets the tags from the submitted form data.
Click on Create | File Upload and upload the sampleadaptiveform.zip
Import the article assets using AEM package manager
Open the sample form in preview mode. Fill in the People section and submit the form.
Navigate to Peak folder in DAM. You should see DoR in the Peak folder. Check the properties of the document. It should be tagged appropriately.
Congratulations!! You have successfully installed the sample on your system
Let’s explore the workflow which gets triggered on form submission.
The first step in the workflow creates a unique file name by concatenating applicants name and county of residence.
The second step of the workflow passes the tag hierarchy and the form fields elements that need to be tagged. The process step extracts the value from the submitted data and constructs the tag title that needs to tag the document.
If you want to store DoR in a different folder in the DAM, you specify the folder location using the configuration properties as specified in the screenshot below.
The other two parameters are specific to DoR and Data File Path as specified in the Adaptive Form submission options. Please make sure the values you specify here match with the values you specified in the Adaptive Form submission options.