ワークフロー通知テンプレート変数¶
対象:Liferay CE/DXP 7.3+
一部の変数は、ワークフローの通知コンテキストに自動挿入されます。 これらは、ワークフローの通知テンプレートで使用すると便利です。
通常、Freemarkerでは、変数を明示的に宣言する必要があります。
<#assign variableName = "Variable Name" />
インジェクトされた変数はすでに宣言されており、テンプレート内で直接使用することができます。
${variableName}
これらの変数を使用するには、ワークフローの通知コンテキストで利用可能な変数を知っておく必要があります。 利用できる変数は、ワークフロー定義の詳細やワークフロー内のアセットに応じて変化します。 ここで紹介する方法は、特定のコンテキストに合わせて変数のリストを取得する方法を示していますので、推測で行う必要はありません。
ワークフロー通知テンプレート変数の確認¶
DEBUGレベルの ロギング を TemplentNotificationMessageGenerator
クラスで有効にして、ワークフローの通知コンテキストで利用可能な変数を表示します。
コントロールパネル → 構成 → サーバーの管理 に移動します。
[Log Levels]タブをクリックします。
この設定でLog Levelを追加します。
ロガー名 :
com.liferay.portal.workflow.kaleo.runtime.internal.notification.TemplateNotificationMessageGenerator
ログレベル :
DEBUG
アセット(Blogs Entryなど)に対して、ワークフロー定義 (唯一の承認者定義など)をアクティブにすることができます。
テストエントリを送信すると、ログメッセージが表示され、ワークフローで使用可能な通知テンプレートの変数が表示されます。
例えば、唯一の承認者のワークフローでは、アセットの初回提出時にこれらの変数が表示されます。
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)
...
上の出力のスニペットを見ると、 saxReaderUtil
, getterUtil
, portalPermission
, entryClassPK
, layoutPermission
, expandoTableLocalService
, localeUtil
, groupId
, portalUtil
は、これらのメッセージがログに出力される原因となったコンテキストで利用可能です。
ワークフロー通知テンプレート変数の使用¶
コンテクストに注入される通知変数は、主に2つのタイプに分類されます。
値 変数は、単一の値を提供します。 変数が単一の値を提供する場合、その値を通知に表示するために使用することができます。また、通知メッセージに表示される他の有用な情報を取得する操作のパラメータとして渡すこともできます。
例: 唯一の承認者の定義では、FreeMarkerのテンプレートでこの通知を提供しています。
${userName} sent you a ${entryType} for review in the workflow.
userName
と entryType
が値を提供しているので、通知は次のように表示されます。
Joe Bloggsさんから、ワークフローで確認するためのブログのエントリが送られてきました。
また、値型変数の内容を確認することもできます。 唯一の承認者の定義には、この通知テンプレートも含まれています。
Your submission was reviewed<#if taskComments?has_content> and the reviewer applied the following ${taskComments}</#if>.
レビュアがタスクコメントを提供した場合は、そのコメントが表示されます。 そうでない場合は、通知の送付先は
あなたの提出物はレビューされました
オペレーション 変数はLiferay DXPのJavaクラスを公開しているので、通知テンプレートでその操作にアクセスすることができます。 これらの変数については、クラスの Javadoc を熟知するか、 ソースコード を見て、その動作を理解する必要があります。
例: このFreeMarkerは、デフォルトのロケールを使用して、特定のパターン(月/日/年、時間:分)で現在の日付を取得します。
${dateUtil.getCurrentDate("MM/dd/yyyy, HH:mm", localeUtil.getDefault())}`
ワークフロー通知テンプレートの変数について¶
これらは、Blogsエントリーの唯一の承認者の定義 を有効にして、新しいエントリーを公開用に送信したときに記録される変数です。
Variable Name |
Value |
Operation |
Description or Link |
---|---|---|---|
${saxReaderUtil} |
✔ |
||
${getterUtil} |
✔ |
||
${portalPermission} |
✔ |
||
${entryClassPK} |
✔ |
The primary key of the Entry Class |
|
${layoutPermission} |
✔ |
||
${expandoTableLocalService} |
✔ |
||
${localeUtil} |
✔ |
||
${groupId} |
✔ |
The ID of the group |
|
${portalUtil} |
✔ |
||
${validator} |
✔ |
||
${dateUtil} |
✔ |
||
${serviceLocator} |
✔ |
||
${serviceContext} |
✔ |
||
${jsonFactoryUtil} |
✔ |
||
${stringUtil} |
✔ |
||
${freeMarkerPortletPreferences} |
✔ |
||
${dateFormats} |
✔ |
||
${dateFormatFactory} |
✔ |
||
${userPortraitURL} |
✔ |
Applies only to Blogs Entries; returns the URL to the User's portrait. |
|
${portal} |
✔ |
||
${commonPermission} |
✔ |
||
${userURL} |
✔ |
Applies only to Blogs Entries; returns the URL to a logged in User's profile page. See . |
|
${expandoValueLocalService} |
✔ |
||
${entryType} |
✔ |
The type of entry in the workflow (e.g., Blogs Entry) |
|
${organizationPermission} |
✔ |
||
${passwordPolicyPermission} |
✔ |
||
${expandoColumnLocalService} |
✔ |
||
${taskComments} |
✔ |
The comments, if any, left by the reviewer |
|
${staticFieldGetter} |
✔ |
||
${htmlUtil} |
✔ |
||
${languageUtil} |
✔ |
||
${enumUtil} |
✔ |
Returns the result of |
|
${windowStateFactory} |
✔ |
||
${companyId} |
✔ |
The ID of the portal's Company/Virtual Instance |
|
${unicodeFormatter} |
✔ |
||
${propsUtil} |
✔ |
||
${browserSniffer} |
✔ |
||
${portletProviderAction} |
✔ |
Returns the outcome of the PortletProvider#Action call |
|
${taskName} |
✔ |
The name of the task the notification is in |
|
${httpUtil} |
✔ |
||
${portletURLFactory} |
✔ |
||
${imageToken} |
✔ |
An image token from WebServerServletToken.getToken(long imageId) ; is deprecated and will be removed |
|
${groupPermission} |
✔ |
||
${timeZoneUtil} |
✔ |
||
${unicodeLanguageUtil} |
✔ |
||
${expandoRowLocalService} |
✔ |
||
${auditRouterUtil} |
✔ |
||
${kaleoTaskInstanceToken} |
✔ |
||
${accountPermission} |
✔ |
||
${httpUtilUnsafe} |
✔ |
Like |
|
${workflowTaskAssignees} |
✔ |
||
${random} |
✔ |
A Java utility for generating Random numbers; is deprecated and will be removed in the future |
|
${rolePermission} |
✔ |
||
${portletPermission} |
✔ |
||
${paramUtil} |
✔ |
||
${locationPermission} |
✔ |
Returns the outcome of |
|
${calendarFactory} |
✔ |
||
${webServerToken} |
✔ |
An image token from WebServerServletToken.getToken(long imageId) |
|
${sessionClicks} |
✔ |
||
${userPermission} |
✔ |
||
${entryClassName} |
✔ |
||
${userGroupPermission} |
✔ |
||
${arrayUtil} |
✔ |
||
${userName} |
✔ |
The User Name of the last user to intervene in the workflow |
|
${userId} |
✔ |
The User ID of the last user to intervene in the workflow. See the Workflow Scripting article to understand the logic. |
|
${prefsPropsUtil} |
✔ |
||
${url} |
✔ |
a URL for certain content types that are displayed on a page (e.g., Blogs Entries, Message Boards Messages, and Wiki Pages |
|
${kaleoInstanceToken} |
✔ |
||
${utilLocator} |
✔ |
||
${objectUtil} |
✔ |
Returns a |
|
${urlCodec} |
✔ |
||
${portletModeFactory} |
✔ |
||
${imageToolUtil} |
✔ |
||
${auditMessageFactoryUtil} |
✔ |
||
${staticUtil} |
✔ |
Returns the result of |