Workflow Notification Template Variables
Liferay 7.3+
Some variables are auto-injected into the workflow notification context. These are handy to use in your workflow notification templates.
Normally in Freemarker, you must declare variables explicitly:
<#assign variableName = "Variable Name" />
Injected variables are already declared and can be used directly in the template.
${variableName}
To use these variables, you must know which are available in your workflow notification context. The variables available change depending on the workflow definition details and the asset in the workflow. The method presented here shows you how to get the list of variables for your specific context, so you don’t have to do any guesswork.
Discovering the Workflow Notification Template Variables
Enable DEBUG level logging for the TemplateNotificationMessageGenerator class to display the variables available in your workflow notification context:
-
Go to Global Menu (
) → Control Panel → Server Administration. -
Click the Log Levels tab.
-
Add a Log Level with this configuration:
- Logger Name:
com.liferay.portal.workflow.kaleo.runtime.internal.notification.TemplateNotificationMessageGenerator - Log Level:
DEBUG
- Logger Name:
-
Activate a workflow definition (e.g., the Single Approver definition) on an asset (e.g., Blogs Entry).
-
Submit a test entry and log messages appear that reveal the workflow available notification template variables in the context of your workflow.
For example, the Single Approver workflow shows these variables on initial submission of an asset:
2020-03-30 14:21:42.089 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] saxReaderUtil (class com.sun.proxy.$Proxy447)
2020-03-30 14:21:42.097 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] getterUtil (class com.liferay.portal.kernel.util.GetterUtil_IW)
2020-03-30 14:21:42.098 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] portalPermission (class com.liferay.portal.service.permission.PortalPermissionImpl)
2020-03-30 14:21:42.098 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] entryClassPK (class java.lang.String)
2020-03-30 14:21:42.098 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] layoutPermission (class com.liferay.portal.service.permission.LayoutPermissionImpl)
2020-03-30 14:21:42.098 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] expandoTableLocalService (class com.sun.proxy.$Proxy43)
2020-03-30 14:21:42.098 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] localeUtil (class com.liferay.portal.kernel.util.LocaleUtil)
2020-03-30 14:21:42.099 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] groupId (class java.lang.String)
2020-03-30 14:21:42.099 DEBUG [liferay/kaleo_graph_walker-2][TemplateNotificationMessageGenerator:94] portalUtil (class com.liferay.portal.util.PortalImpl)
...
The snippet of output above shows that saxReaderUtil, getterUtil, portalPermission, entryClassPK, layoutPermission, expandoTableLocalService, localeUtil, groupId, and portalUtil are available in the context that caused these messages to be printed in the log.
Using the Workflow Notification Template Variables
The contextually injected notification variables can be categorized into two main types: