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:

  • A user fills out Adaptive Form. In the adaptive form, the user's marital status(ex Single) and employment status (Ex Retired)is captured.
  • On form submission, an AEM Workflow is triggered. This workflow tags the document with the marital status(Single) and employment status(Retired) and stores the document in DAM.
  • Once the document is stored in DAM, the administrator should be able to search the document by these tags. For example search on Single or Retired would fetch the appropriate DoR's.

 

To satisfy this use case a custom process step was written. In this step we fetch the valus of the approrpiate 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);

Download

To test this sample on your local server please follow the following steps:

  • Import the Sample Adaptive Form by pointing your browser to Forms and Documents. Click on Create | File Upload.
  • Import and install the article assets using the 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.
  • 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.

tag_dor_service_configuration

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy