Overview

Execution (action/command becomes active) on selection of single, multiple assets/letters, or without selection

This customization is demonstrated with the scenario that adds a command "Download Flat PDF" to the Asset Listing view for Letters. This customization scenario allows your users to download flat PDF of a single selected letter.

Prerequisites

To complete the following scenario or a similar one, you require knowledge of:

CRX

JavaScript

Java

Scenario: Add a command to the Letters list user interface to download flat PDF version of a letter

The below steps add a command "Download Flat PDF" to the Asset Listing view for Letters and allows your users to download flat PDF of the selected letter. Using these steps with the appropriate code and parameters, you can add some other functionality for a different asset, such as data dictionaries or texts.

To customize Correspondence Management to allow your users to download a flat PDF of letters, complete the following steps:

Go to http://[server]:[port]/[ContextPath]/crx/de and login as Administrator.

In the apps folder, create a folder named items with path/structure similar to the items folder located in selection folder using the following steps:

Right-click the items folder at the following path and select Overlay Node:

This path is specific to creating an action that works with selection of one of more assets/letters. If you want to create an action that works without selection, you need to create an overlay node for the following path instead and complete the remaining steps accordingly:

The code you add in this step overrides the code under the libs folder, so copy the previous code to formaction.js file in the /apps branch. Copying the code from the /libs branch to the /apps branch ensures that the previous functionality also works.

The above code is for letters-specific action handling of the command created in this procedure. For action handling of other assets, modify the JavaScript code.

In the apps folder, create a folder named items with path/structure similar to the items folder located in actionhandlers folder using the following steps:

Right-click the items folder at the following path and select Overlay Node:

/libs/fd/cm/ma/gui/content/commons/actionhandlers/items/

Ensure that the Overlay Node dialog has the following values:

Path: /libs/fd/cm/ma/gui/content/commons/actionhandlers/items/

Location: /apps/

Match Node Types: Selected

Click OK. The folder structure is created in the apps folder.

Click Save All.

Under the newly created items node, add a node for the custom button/action in a particular asset (Example: letterpdfdownloader) using the following steps:

Right click the items folder and select Create > Create Node.

Ensure that the Create Node dialog has the following values and click OK:

Name: letterpdfdownloader (Or the name you want to give to this property - must be unique. If you use a different name here, also specify the same in the formaction.js file's ACTION_URL variable.)

Type: nt:unstructured

Click the new node you have created (here downloadFlatPDF). CRX displays the node's properties.

Add the following property to the node (here letterpdfdownloader) and click Save All:

Name

Type

Value

sling:resourceType

String

fd/cm/ma/gui/components/admin/clientlibs/admin

Create a file named POST.jsp with the code for action handling of the command at the following location:

/apps/fd/cm/ma/gui/components/admin/clientlibs/admin

Right-click the admin folder at the following path and select Create > Create File:

/apps/fd/cm/ma/gui/components/admin/clientlibs/admin

Name the file as POST.jsp. (The filename needs to be POST.jsp only.)

Double-click the POST.jsp file to open it in CRX.

Add the following code to POST.jsp file and click Save All:

This code is specific to the letter render service. For any other asset, add that asset's java libraries to this code. For more information on AEM Forms APIs, see AEM Forms API.