AEM Forms 6.3 introduces new capabilities providing review and approval of form data submissions

With the 6.3 release of AEM Forms there is now support for routing of forms data for review and approval type workflows.  The benefit of this is there is no longer the requirement for a JEE server or database.  It also utilizes the AEM InBox that AEM customers may already be familiar.  Also authoring uses a browser instead of Windows Workbench meaning non Windows users will now be able to create forms based workflow processes.

 

This article provides a practical step by step guide to implementing a AEM Workflow forms data submission process.  In the 6.3 release there are three new elements to ease these processes.

 

  • Assign Task - places a form within the AEM Workflow InBox queue allowing for a user to review approve/reject or other workflow defined selections

 

  • Generate Document of Record - merges form data with a template to create a non-interactive PDF document suitable for storage, a welcome kit, or for signing/printing.

 

  • Sign Document - sends a document to Adobe Sign for single/multi signatures

This article will walk through the submission of an Adaptive Form that will perform the following:

  • Initial review of the submission by an intake person
  • Route the form based on a form data element
  • Route the form based on user selected option
  • Generate a PDF Document of Record
  • Send the Document of Record for signing with Adobe Sign

Step 1 - Simple Form Submission

This step will show how to create a form and associate a workflow using an assign task.

AEM Workflow Integration - Part 1 task

AEM Workflow Integration - Part 1 task

AEM Workflow Integration - Part 1 how

AEM Workflow Integration - Part 1 how

Step 2 - Route to a queue based on the content of a field.

This step shows how to follow one of two routes based upon the content of a form field.


Below is the code sample that shows how to get the data for the particular workflow task, load it into a DOM and using XPATH locate the content of a particular field.

function check() {
 
//Define service constants
var FConstant = sling.getService(com.day.cq.commons.jcr.JcrConstants);
var FException = sling.getService(com.day.cq.workflow.WorkflowException);
var FSession = sling.getService(com.day.cq.workflow.WorkflowSession);
var FWorkItem = sling.getService(com.adobe.granite.workflow.exec.WorkItem);
var FMetaMap = sling.getService(com.day.cq.workflow.metadata.MetaDataMap);
var FDom = sling.getService(org.w3c.dom.Document);
var RResolver = sling.getService(org.apache.sling.api.resource.ResourceResolver);
var RRFactory = sling.getService(org.apache.sling.api.resource.ResourceResolverFactory);
 
//Get the path to the form data in the AEM Repository
var logger = Packages.org.slf4j.LoggerFactory.getLogger("AEMFormLogger");
logger.info("Branch1");
var payloadPath = workflowData.getPayload().toString();
payloadPath = payloadPath + "/data.xml/jcr:content"
 
//Read the data for this task into and data DOM
var node = jcrSession.getNode(payloadPath);
var is = node.getProperty("jcr:data").getStream();
var docBuilder = sling.getService(Packages.javax.xml.parsers.DocumentBuilder);
var docBuilderFactory = sling.getService(Packages.javax.xml.parsers.DocumentBuilderFactory);
var xmlDocument = sling.getService(Packages.org.w3c.dom.Document);
var paramsMap = Packages.java.util.Map;
var paramsHashMap =  new Packages.java.util.HashMap();
var factory =  Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
var builder = factory.newDocumentBuilder();
var xmlData = builder.parse(is);
is.close();
 
//Use an XPath statement to locate the form data element and evaluate its value
var xPath = Packages.javax.xml.xpath.XPathFactory.newInstance().newXPath();
var XPathResult = Packages.javax.xml.xpath.XPathConstants;
logger.info(xPath.evaluate('//preTaxMonthlyIncome',xmlData,XPathResult.STRING));
if (xPath.evaluate('//preTaxMonthlyIncome',xmlData,XPathResult.STRING) == '100000') {
   return true;
}
else {
  return false;
}
 
}

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