Using system generated metadata in an email notification
An AEM Forms application provides several metadata variables (key-value pairs) out of the box. You can use these variables in an email template. The value of the variable is based on the associated forms application. The following table lists all the metadata variables available out of the box:
Using custom metadata in an email notification
You can also use custom metadata in an email notification. Custom metadata contains information in addition to system-generated metadata. For example, policy details retrieved from a database. You can use an ECMAScript or OSGi bundle to add custom metadata in crx-repository:
Use ECMAScript to add custom metadata
ECMAScript is a scripting language. It is used for client-side scripting and server applications. Perform the following steps to use ECMAScript to add custom metadata for an email template:
-
Log in to CRX DE with an administrative account. The URL is
https://[server]:[port]/crx/de/index.jsp
-
Navigate to /apps/fd/dashboard/scripts/metadataScripts. Create a file with extension .ecma. For example, usermetadata.ecma
If the above-mentioned path does not exist, create it.
-
Add code to the .ecma file that has the logic to generate custom metadata in key-value pairs. For example, the following ECMAScript code generates custom metadata for an insurance policy:
function getUserMetaData() { //Commented lines below provide an overview on how to set user metadata in map and return it. var HashMap = Packages.java.util.HashMap; var valuesMap = new HashMap(); valuesMap.put("policyNumber", "2017568972695"); valuesMap.put("policyHolder", "Adobe Systems"); return valuesMap; }
-
Click Save All. Now, the script is available for selection in AEM workflow model.
-
(Optional) Specify the title of the script:
If you do not specify the title, the Custom Metadata field displays the complete path of the ECMAScript file. Perform the following steps to specify a meaningful title for the script:
-
Expand the script node, right-click the jcr:content node, and click Mixins.
-
Type mix:title in Edit Mixins dialog and click +.
-
Add a property with the following values.
Name jcr:title Type String Value Specify the title of the script. For example, custom metadata for the policy holder. The specified value is displayed in the assign task step.
-