The Correspondence Management solution allows you add custom actions to the Create Correspondence user interface.
The scenario in this document explains how you can create a button in the Create Correspondence User Interface to share a letter as a review PDF attached to an email.
To complete this scenario, you require the following:
- Knowledge of CRX and JavaScript
- LiveCycle Server
Adding a button with an action (here send letter for review) to the Create Correspondence User Interface includes:
- Adding the button to the Create Correspondence User Interface
- Adding action handling to the button
- Adding the LiveCycle process to enable action handling
-
<?xml version="1.0" encoding="utf-8"?> <extensionsConfig> <modelExtensions> <modelExtension type="LetterInstance"> <customAction name="Preview" label="loc.letterInstance.preview.label" tooltip="loc.letterInstance.preview.tooltip" styleName="previewButton"/> <customAction name="Submit" label="loc.letterInstance.submit.label" tooltip="loc.letterInstance.submit.tooltip" styleName="submitButton" permissionName="forms-users"/> <customAction name="SaveAsDraft" label="loc.letterInstance.saveAsDraft.label" tooltip="loc.letterInstance.saveAsDraft.tooltip" styleName="submitButton" permissionName="forms-users"/> <customAction name="Close" label="loc.letterInstance.close.label" tooltip="loc.letterInstance.close.tooltip" styleName="closeButton"/> </modelExtension> </modelExtensions> </extensionsConfig>
-
To email letter, you can use LiveCycle Forms Workflow. Add a customAction tag under the modelExtension tag in acmExtensionsConfig.xml as following:
<customAction name="Letter Review" label="Letter Review" tooltip="Letter Review" styleName="" permissionName="forms-users" actionHandler="CM.domain.CCRCustomActionHandler"> <serviceName>Forms Workflow -> SendLetterForReview/SendLetterForReviewProcess</serviceName> </customAction>
The modelExtension tag has a set of customAction child tags that configure the action, permissions, and appearance of the action button. Following is the list of customAction configuration tags:
Name Description name The alphanumeric name for the action to perform. Value of this tag is required, must be unique (within the modelExtension tag), and must start with an alphabet. label The label to display on the action button tooltip Tool tip text of the button, which is displayed when the user hovers over the button. styleName Name of the custom style that is applied on the action button. permissionName The corresponding action is displayed only if user has the permission specified by permissionName. When you specify permissionName as forms-users, all the users get access to this option. actionHandler Fully qualified name of the ActionHandler class that is called when user clicks the button. Apart from the above parameters, there can be additional configurations associated with a customAction. These additional configurations are made available to the handler through the CustomAction object.
Name Description serviceName If a customAction contains a child tag with name serviceName, then on clicking of the relevant button/link, a process is called with the name represented by serviceName tag. Ensure this process has the same signature as the Letter PostProcess. Add "Forms Workflow ->" prefix in service name. Parameters containing cm_ prefix in tag name If a customAction contains a child tags starting with name cm_, then in post process (be it Letter Post Process or the special process represented by serviceName tag) these parameters are available in the input XML code under the relevant tag with cm_ prefix removed. actionName Whenever a post process is due to a click, submitted XML contains a special tag with name under the tag with the name of the user action.
The ACMExtensionsMessages.properties file includes labels and tooltip messages of various fields in Create Correspondence user interface. For the customized actions/buttons to work, make a copy of this file in the /apps branch.
-
To localize the labels of the newly added custom action/button, create the ACMExtensionsMessages.properties file for the relevant locale in /apps/fd/cm/config/defaultApp/locale/.
For example, for localizing the custom action/button created in this article, create a file named ACMExtensionsMessages_fr.properties with the following entry:
loc.letterInstance.letterreview.label=Revue De Lettre
Similarly, you can add more properties, such as for tooltip and style, in this file.
After making every server-side change, restart the Adobe Asset Composer Building Block bundle. In this scenario, the acmExtensionsConfig.xml and ACMExtensionsMessages.properties files on the server-side are edited, and hence the Adobe Asset Composer Building Block bundle requires a restart.
註解:
You may need to clear the browser cache.
After restarting the Adobe Asset Composer Building Block bundle, the custom button appears in the Create Correspondence User Interface. You can open a letter in the Create Correspondence User Interface to preview the custom button.
The Create Correspondence user interface by default has implementation of ActionHandler in the cm.domain.js file at the following location:
/libs/fd/cm/ccr/gui/components/admin/clientlibs/ccr/js/cm.domain.js
For custom action handling, create an overlay of the cm.domain.js file in the /apps branch of CRX.
Handling the action/button on clicking action/button includes logic for:
- Making the newly added action as visibe/invisible: done by overriding the actionVisible() function.
- Enabling/disabling newly added action: done by overriding the actionEnabled() function.
- Actual handling of action when user clicks the button: done by overriding the implementation of the handleAction() function.
-
In the js folder, create a file named ccrcustomization.js with the code for action handling of the button using the following steps:
-
/* for adding and handling custom actions in Extensible Toolbar. * One instance of handler will be created for each action. * CM.domain.CCRCustomActionHandler is actionHandler class. */ var CCRCustomActionHandler; CCRCustomActionHandler = CM.domain.CCRCustomActionHandler = new Class({ className: 'CCRCustomActionHandler', extend: CCRDefaultActionHandler, construct : function(action,model){ } }); /** * Called when user user click an action * @param extraParams additional arguments that may be passed to handler (For future use) */ CCRCustomActionHandler.prototype.handleAction = function(extraParams){ if (this.action.name == CCRCustomActionHandler.SEND_FOR_REVIEW) { var sendForReview = function(){ var serviceName = this.action.actionConfig["serviceName"]; var inputParams = {}; inputParams["dataXML"] = this.model.iccData.data; inputParams["letterId"] = this.letterVO.id; inputParams["letterName"] = this.letterVO.name; inputParams["mailId"] = $('#email').val(); /*function to invoke the LivecyleService */ ServiceDelegate.callJSONService(this,"lc.icc.renderlib.serviceInvoker.json","invokeProcess",[serviceName,inputParams],this.onProcessInvokeComplete,this.onProcessInvokeFail); $('#ccraction').modal("hide"); } if($('#ccraction').length == 0){ /*For first click adding popup & setting letterName.*/ $("body").append(popUp); $("input[id*='letterName']").val(this.letterVO.name); $(document).on('click',"#submitLetter",$.proxy( sendForReview, this )); } $('#ccraction').modal("show"); } }; /** * Should the action be enabled in toolbar * @param extraParams additional arguements that may be passed to handler (For future use) * @return flag indicating whether the action should be enabled */ CCRCustomActionHandler.prototype.actionEnabled = function(extraParams){ /*can be customized as per user requirement*/ return true; }; /** * Should the action be visible in toolbar * @param extraParams additional arguments that may be passed to handler (For future use) * @return flag indicating whether the action should be enabled */ CCRCustomActionHandler.prototype.actionVisible = function(extraParams){ /*Check can be enabled for Non-Preview Mode.*/ return true; }; /*SuccessHandler*/ CCRCustomActionHandler.prototype.onProcessInvokeComplete = function(response) { ErrorHandler.showSuccess("Letter Sent for Review"); }; /*FaultHandler*/ CCRCustomActionHandler.prototype.onProcessInvokeFail = function(event) { ErrorHandler.showError(event.message); }; CCRCustomActionHandler.SEND_FOR_REVIEW = "Letter Review"; /*For PopUp*/ var popUp = '<div class="modal fade" id="ccraction" tabindex="-1" role="dialog" aria-hidden="true">'+ '<div class="modal-dialog modal-sm">'+ '<div class="modal-content">' + '<div class="modal-header">'+ '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>'+ '<h4 class="modal-title"> Send Review </h4>'+ '</div>'+ '<div class="modal-body">'+ '<form>'+ '<div class="form-group">'+ '<label class="control-label">Email Id</label>'+ '<input type="text" class="form-control" id="email">'+ '</div>'+ '<div class="form-group">'+ '<label class="control-label">Letter Name</label>'+ '<input id="letterName" type="text" class="form-control" readonly>'+ '</div>'+ '<div class="form-group">'+ '<input id="letterData" type="text" class="form-control hide" readonly>'+ '</div>'+ '</form>'+ '</div>'+ '<div class="modal-footer">'+ '<button type="button" class="btn btn-default" data-dismiss="modal"> Cancel </button>'+ '<button type="button" class="btn btn-primary" id="submitLetter"> Submit </button>'+ '</div>'+ '</div>'+ '</div>'+ '</div>';
In this scenario, enable the following components, which are a part of the attached components.zip file:
- DSC component jar (DSCSample.jar)
- Send letter for review process LCA (SendLetterForReview_6_2.lca)
下載
註解:
This step is required only if you are on an OSGI setup and LC integration is required for the type of customization you are implementing.
The LCA process runs on the LiveCycle server and requires the server address and the login credentials.
註解:
To view what this process does or to create a similar process of your own, you need Workbench.
In this scenario, for Correspondence Management to be able to send an email, configure the email service in the LiveCycle server.
To use the Correspondence Management API, download the DSCSample.jar (attached in this document as part of components.zip) and upload it to the LiveCycle server. After the DSCSample.jar file is uploaded to the LiveCycle server, the AEM server uses the DSCSample.jar file to access the renderLetter API.
For more information, see Connecting AEM Forms with Adobe LiveCycle.
-
Provide the following parameters in configuration file:
- crx.serverUrl=http:/[host]/:[port]/[context path]/[AEM URL]
- crx.username= AEM user name
- crx.password= AEM password
- crx.appRoot=/content/apps/cm
註解:
Every time you make any changes at the server sidde, restart the LiveCycle Server. For information on creating your own LiveCycle component, see Extending LiveCycle ES software through custom DSC development.
The DSCSample.jar file uses the renderLetter API. For more Information about the renderLetter API, see Interface LetterRenderService.
DSCSample.jar file uses the renderLetter API to render letter as PDF bytes from XML data that C give as input. For more Information about the renderLetter and other APIs, see Letter Render Service.
After you have configured the action and button for sending the letter for review:
1. Clear the browser cache.
2. In the Create Correspondence UI, click Letter Review and specify the reviewer's email ID.
3. Click Submit.
