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:
-
Launch Workbench. Log in to localhost as administrator.
-
Click File > New > Application. In the Application Name field, enter
CMDemoSample
and then click Finish. -
Select
CMDemoSample/1.0
and right-clickNewProcess
. In the name field, enterCMRenderer
and then click Finish. -
Drag the Start Point activity picker and configure it:
-
In Presentation Data, select Use A CRX Asset.
-
Browse for an asset. In the Select Form Asset dialog, the Letters tab lists all the letters on the server.
-
Select the appropriate letter and click OK.
-
-
Click Manage Action Profiles. The Manage Action Profile dialog appears. Ensure that the Render Process and Submit Process are appropriately selected.
-
To open the letter with a data XML file, browse and select the appropriate data file in the Prepare Data Process.
-
Click OK.
-
Define the variables for Start Point Output and Task Attachments. The defined variables contain Start Point Output and Task Attachments data.
-
(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.
-
Deploy the application. If prompted check-in and save the assets.
-
Log in to the AEM forms workspace at https://‘[server]:[port]’/lc/content/ws.
-
Open the task that you had added, CMRenderer. The Correspondence Management letter appears.
-
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.