Integrating third-party applications in AEM Forms workspace integrating-third-party-applications-in-aem-forms-workspace

AEM Forms workspace supports the management of task assignment and completion activities for forms and documents. These forms and documents can be XDP Forms, Flex® forms, or Guides (deprecated) that have been rendered in XDP, PDF, HTML, or Flex formats.

These capabilities are further enhanced. AEM Forms now support collaboration with third-party applications that support functionality similar to the AEM Forms workspace. A common part of this functionality is the workflow of assignment and subsequent approval of a task. AEM Forms provides a single unified experience for AEM Forms enterprise users so that all such task assignments or approvals for the supported applications can be handled through the AEM Forms workspace.

As an example, let us consider Correspondence Management as the sample candidate for integration with AEM Forms workspace. Correspondence Management has the concept of a ‘Letter’, which can be rendered and allows actions.

Create Correspondence Management assets create-correspondence-management-assets

Start by creating a sample Correspondence Management template that is rendered in the AEM Forms workspace. For more details, see Create a letter template.

Access the Correspondence Management template at its URL to verify if the Correspondence Management template can be rendered successfully. The URL has a pattern similar to https://'[server]:[port]'/lc/content/cm/createcorrespondence.html?cmLetterId=encodedLetterId&cmUseTestData=1&cmPreview=0;

Where encodedLetterId is the URL-encoded letter Id. Specify the same letter Id, when defining the render process for workspace task in Workbench.

Create a task to render and submit a letter in AEM Workspace create-a-task-to-render-and-submit-a-letter-in-aem-workspace

Before executing these steps, ensure that you are a member of the following groups:

  • cm-agent-users
  • Workspace Users

For more information, see Add and configure users.

Use the following steps to create a task to render and submit a letter in AEM Workspace:

  1. Launch Workbench. Log in to localhost as administrator.

  2. Click File > New > Application. In the Application Name field, enter CMDemoSample and then click Finish.

  3. Select CMDemoSample/1.0 and right-click NewProcess. In the name field, enter CMRenderer and then click Finish.

  4. Drag the Start Point activity picker and configure it:

    1. In Presentation Data, select Use A CRX Asset.


    2. Browse for an asset. In the Select Form Asset dialog, the Letters tab lists all the letters on the server.

      Letter tab

    3. Select the appropriate letter and click OK.

  5. Click Manage Action Profiles. The Manage Action Profile dialog appears. Ensure that the Render Process and Submit Process are appropriately selected.

  6. To open the letter with a data XML file, browse and select the appropriate data file in the Prepare Data Process.

  7. Click OK.

  8. Define the variables for Start Point Output and Task Attachments. The defined variables contain Start Point Output and Task Attachments data.

  9. (Optional) To add another user in the workflow, drag an activity picker, configure it, and assign it to a user. Write a custom wrapper (sample given below) or download and install the DSC (given below) to extact Letter template, Start Point Output, and task Attachment.

    A sample custom wrapper is as listed below:

    code language-javascript
    public LetterInstanceInfo getLetterInstanceInfo(Document dataXML) throws Exception {
    try {
    if(dataXML == null)
    throw new Exception("dataXML is missing");
    CoreService coreService = getRemoteCoreService();
    if (coreService == null)
    throw new Exception("Unable to retrive service. Please verify connection details.");
    Map<String, Object> result = coreService.getLetterInstanceInfo(IOUtils.toString(dataXML.getInputStream(), "UTF-8"));
    LetterInstanceInfo letterInstanceInfo = new LetterInstanceInfo();
    List<Document> attachmentDocs = new ArrayList<Document>();
    List<byte[]> attachments = (List<byte[]>)result.get(CoreService.ATTACHMENT_KEY);
    if (attachments != null){
    for (byte[] attachment : attachments)
    { attachmentDocs.add(new Document(attachment)); }
    byte[] updateLayout = (byte[])result.get(CoreService.LAYOUT_TEMPLATE_KEY);
    if (updateLayout != null)
    { letterInstanceInfo.setLetterTemplate(new Document(updateLayout)); }
    { throw new Exception("template bytes missing while getting Letter instance Info."); }
    return letterInstanceInfo;
    } catch (Exception e)
    { throw new Exception(e); }

    Get File
    Download DSC: A sample DSC is available in the file attached above. Download and unzip the file. Before you use the DSC service, you must configure it. See Configure the DSC Service.

    In the Define Activity dialog, select the appropriate activity such as getLetterInstanceInfo and click OK.

  10. Deploy the application. If prompted check-in and save the assets.

  11. Log in to the AEM forms workspace at https://‘[server]:[port]’/lc/content/ws.

  12. Open the task that you had added, CMRenderer. The Correspondence Management letter appears.


  13. Fill in the required data and submit the letter. The window closes. In this process, the task gets assigned to the user specified in the workflow in step 9.

    note note
    The Submit button is not enabled until all the required variables in the letter are filled in.