我在Liferay 6.2中实施了一个简单的单一批准Kaleo Workflow。
我的要求是,在资产获得批准后,通知会发送给创建资产的用户。
通知“您的申请已获批准”未发送给创建资产的用户。下面是我的Workflow XML。
<?xml version="1.0" encoding="UTF-8"?>
<workflow-definition xmlns="urn:liferay.com:liferay-workflow_6.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:liferay.com:liferay-workflow_6.2.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_2_0.xsd">
<name>Test</name>
<version>1</version>
<state>
<name>Created</name>
<metadata><![CDATA[{"transitions":{"to_pending":{"bendpoints":[],"xy":[-26,-20]},"sent":{"bendpoints":[]},"ToPending":{"bendpoints":[],"xy":[-26,-20]},"CreatorCheck":{"bendpoints":[],"xy":[-36,10]}},"xy":[63,82]}]]></metadata>
<initial>true</initial>
<transitions>
<transition>
<name>ToPending</name>
<target>PendingTask</target>
</transition>
</transitions>
</state>
<task>
<name>PendingTask</name>
<metadata><![CDATA[{"transitions":{"Approved":{"bendpoints":[],"xy":[-36,10]},"Rejected":{"bendpoints":[]}},"xy":[220,70]}]]></metadata>
<actions>
<notification>
<name>NotifyEveryone</name>
<template>Task is in pending state.</template>
<template-language>velocity</template-language>
<notification-type>user-notification</notification-type>
<execution-type>onEntry</execution-type>
</notification>
<notification>
<name>RejectedNotification</name>
<template>Your Request has been rejected!</template>
<template-language>velocity</template-language>
<notification-type>user-notification</notification-type>
<recipients>
<user />
</recipients>
<execution-type>onExit</execution-type>
</notification>
<notification>
<name>ApprovedNotification</name>
<template>Your Request has been Approved!</template>
<template-language>velocity</template-language>
<notification-type>user-notification</notification-type>
<recipients>
<user />
</recipients>
<execution-type>onExit</execution-type>
</notification>
</actions>
<assignments>
<roles>
<role>
<role-type>regular</role-type>
<name>Portal Content Reviewer</name>
<auto-create>true</auto-create>
</role>
</roles>
</assignments>
<transitions>
<transition>
<name>Approved</name>
<target>Approved</target>
</transition>
<transition>
<name>Rejected</name>
<target>Rejected</target>
</transition>
</transitions>
</task>
<state>
<name>Approved</name>
<metadata><![CDATA[{"terminal":true,"xy":[413,52]}]]></metadata>
<actions>
<action>
<name>Approved</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil
import com.liferay.portal.kernel.workflow.WorkflowConstants
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.STATUS_APPROVED, workflowContext)
]]>
</script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
<notification>
<name>newNotification1</name>
<template>Your Request has been Approved</template>
<template-language>text</template-language>
<notification-type>user-notification</notification-type>
<execution-type>onEntry</execution-type>
</notification>
</actions>
</state>
<state>
<name>Rejected</name>
<metadata><![CDATA[{"terminal":true,"xy":[413,144]}]]></metadata>
<actions>
<action>
<name>Rejected</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil
import com.liferay.portal.kernel.workflow.WorkflowConstants
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.STATUS_DENIED, workflowContext)
]]></script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
</actions>
</state>
</workflow-definition>
我确实检查了以下链接
在第二个链接中,Vishal指定了
我们可以在&lt; task&gt;中使用以下标记标签只能在&lt; state&gt;中标签
如果是这种情况,我该如何实现我的要求?我可以添加另一个任务,它将发送通知,然后调用“批准”状态??
修改 根据需要添加了“已拒绝”状态。同时为 Saleem Khan 和 Jozef Chocholacek 指出的已创建请求的用户添加了已批准和已拒绝的通知消息
现在,无论资产是“已批准”还是“已拒绝”,都会发送通知。在“拒绝”中,必须发送不同的消息。如何检查资产是否已批准或已拒绝并发送不同的消息?
答案 0 :(得分:1)
将通知放入<task>
,并设置<execution-type>onExit</execution-type>
应该会有所帮助。
答案 1 :(得分:1)
将以下代码添加到“审批状态”中的通知
<recipients>
<user />
</recipients>
这会将通知发送给创建资产的用户