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.

      useacrxasset

    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:

    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)); }
    
    }
    letterInstanceInfo.setLetterAttachments(attachmentDocs);
    
    byte[] updateLayout = (byte[])result.get(CoreService.LAYOUT_TEMPLATE_KEY);
    if (updateLayout != null)
    { letterInstanceInfo.setLetterTemplate(new Document(updateLayout)); }
    
    else
    { 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 DSCSample.zip file attached above. Download and unzip the DSCSample.zip 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.

    cminworkspace

  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
    The Submit button is not enabled until all the required variables in the letter are filled in.