問題
- portal.properties で提供されるデフォルトとは異なる、ワークフロー通知用のカスタム電子メールアドレスまたは送信者名を指定する方法:
workflow.email.from.name=test workflow.email.from.address=test@liferay.com
環境
- 四半期ごとのリリース
- 7.3
- 7.4
解像度
送信者の名前とメールアドレスは、デフォルトでportal.propertiesに設定されています:
workflow.email.from.name=
workflow.email.from.address=
ワークフローごとに異なる送信者を設定したい場合は、通知タスクの実行時にワークフローコンテキストを変更して、それらのプロパティを直接提供することができます:
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"newSenderName");
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"newSenderName@newSenderName.com");
この変更を適用するには、"Single approver "ワークフローに基づき、以下のステップに従ってください:
- ワークフロー・コードを開き、通知を関連付けた "タスク "エレメントに移動します。
- コンテキストにsenderNameとsenderAddressを含む "action "タイプの新しいノードを追加する。
- 最後に、serviceContext に workflowContext を設定する。
これがその適用方法だ:
<action>
<name>review</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME,"senderName");
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS,"sender.mail@liferay.com");
serviceContext.setAttribute("workflowContext", workflowContext);
]]>
</script>
<script-language>groovy</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>Review Notification</name>
<template>
<![CDATA[${userName} sent you a ${entryType} for review in the workflow.]]>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<assignees />
</recipients>
<execution-type>onAssignment</execution-type>
</notification>
定数workflowConstants.CONTEXT_NOTIFICATION_SENDER_NAMEと workflowConstants.CONTEXT_NOTIFICATION_SENDER_EMAILは、クラスEmailNotificationSender.javaで読み込まれます。
- ワークフローコンテキストに由来するものであれば、それは常に採用される。
- そうでない場合は、先に述べたプロパティで設定されたものが使われる。