Designing a Correspondence Draft workflow

Saving correspondences as a draft (i.e., an in-progress correspondence), and the ability to reopen the same at a later point in time, seems to be a common use case in Correspondence Management.

While it is known that the Adobe CM solution can be easily extended to save correspondence drafts by following some very simple steps, I would like to enlighten as to how one could extend beyond that to design an end-to-end workflow around it.

Summary

In a nutshell, this post talks about the steps you could follow to Save your correspondence drafts (in the CRX repository), load the (list of) saved drafts on the Manage Assets interface and then (usually at a later point in time) choose a particular draft to be re-opened in the Create Correspondence interface.

The same workflow can have multiple iterations, depending upon the number of steps taken to author the final correspondence.

Details

Here are the steps that you could follow to design such a correspondence draft workflow :

The steps below involve code changes (both Flex and Java), so please ensure that you have setup your development environment correctly, before proceeding.

Step 1 : Save correspondence drafts from Create Correspondence

Your first step would be to enable Save As Draft functionality on the Create Correspondence UI. After these changes, you will have a new SaveAsDraft button on your Create Correspondence UI, that can be clicked to invoke the postprocess (an ADEP process) designed and configured for that button.

If you are new to designing postprocesses for the solution, it is highly recommended that you read more on designing postprocesses.

We will now look into what needs to be done in the process…

Step 2 : Postprocess definition to save drafts

In the ADEP process that you design for Step 1, save the XML data (given to the postprocess) onto a given location in the CRX repository as a node (of type XML), with the Letter template name as a property on that node. You may add other details (properties) to the node such as the username who saved the correspondence , timestamp when the draft was saved, comments captured from the user when saving the draft, etc.

Your saved draft nodes may look like this (assuming you save them under /content/CMDrafts) :

 

 

 

 

 

 

Step 3: Custom OSGi Service to fetch drafts

Now that you have a process that saves your correspondences in the CRX repository as nodes, you need the ability to fetch those from CRX (so that they can be enlisted).

Use/customize the CM Solution Template’s Services (Java) project to define an OSGi service that can fetch the XML data nodes (and their details/properties) from CRX. The first couple of steps in this post indicate how to write an OSGi service and expose it over Flex and Spring remoting (note that you do not need the other steps, since the Services project is already configured to do that for you).

Your service would return a List of a custom value object, say DraftVO, which contains the XML data URL string (URL to node in the CRX repository, which would be something like crx:///content/CMDrafts/SampleLetterDraft1.xml) and the other properties attached to the draft’s node (created in Step 2).

Additionally, your service could filter the list of drafts based on the logged in user, so that a user only sees the drafts saved by him/her. Of course, you need to ensure that Step 2 persists the username within the node properties (to filter the appropriate nodes).

Step 4: List Drafts on the Manage Assets

Now that you have a service which can return you a list of drafts saved in the system, you can customize the Manage Assets UI to enlist these drafts.

To do so, you can start by adding a new tab, say “Drafts“, alongside the existing tabs on the Manage Assets interface. When you launch the Manage Assets UI after these changes, it should look something like this:

 

 

 

 

The Drafts tab can be designed such that it contains a DataGrid which will enlist the saved drafts within the grid, by invoking the service, that we defined in Step 3, as the data provider. The columns to be shown in the grid would depend on what properties you have saved (in Step 2) for a given draft item.

The below snapshot is a sample that shows two columns for the drafts list – the Letter template used for the draft, and the time when the draft was saved (assuming that the user is only seeing drafts loaded by him/her).

 

 

 

 

Step 5: Reload selected draft

Before you proceed, if you are not already aware of reloading correspondences in CM, please ensure that you read through how to reload a correspondence in CM.

So, now that you have fetched the list of drafts on the UI, you would add a toolbar above your data grid, that has a button Reload (see snapshot above). The button should have a click handler, such that when you select a draft item, and click Reload, it launches the CCR UI with the URL http://server:port/cm/createcorrespondence.html?cmDataUrl=<the data URL for the selected Draft item>. The data URL would be available to you for each item through the DraftVO that your service returns in Step 3.

 

That’s it, you now have an end-to-end workflow for saving and reloading correspondence drafts!

Note that this is just an example that shows the solution’s extension and core capabilities to design such a workflow. You may tweak this to have more steps within it, design a more sophisticated UI, or extend this further depending upon the actual requirements.