【问题标题】:Liferay Workflow Notification based on Approve or Reject State基于批准或拒绝状态的 Liferay 工作流通知
【发布时间】:2015-08-07 09:00:31
【问题描述】:

我在 Liferay 6.2 中实现了一个简单的单一批准 Kaleo 工作流程。

我的要求是在资产获得批准后向创建资产的用户发送通知。

您的请求已获批准”通知未发送给创建资产的用户。下面是我的工作流 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>

我确实检查了以下链接

  1. Designing workflows with Kaleo Designer for Java

  2. Use Workflow To Send Notification ONLY

在第二个链接中,Vishal 已指定

我们可以在 标签中有以下标签,但在 标签中没有。

如果是这种情况,我该如何实现我的要求?我可以添加另一个发送通知然后调用“批准”状态的任务吗?

编辑 根据需要添加了“拒绝”状态。还为 Saleem KhanJozef Chocholacek

指出的创建请求的用户添加了已批准和已拒绝的通知消息

现在,无论资产是“批准”还是“拒绝”,都会发送通知。在“拒绝”上,必须发送不同的消息。如何检查资产是被批准还是被拒绝并发送不同的消息?

【问题讨论】:

    标签: liferay workflow liferay-6


    【解决方案1】:

    将通知放入&lt;task&gt;,并设置&lt;execution-type&gt;onExit&lt;/execution-type&gt; 应该会有所帮助。

    【讨论】:

    • 是的,我已按照您的建议添加了通知,但现在我处于“拒绝”状态,需要根据资产是“批准”还是“拒绝”发送通知。有什么想法吗??
    • 向通知模板添加一些逻辑,例如使用transitionName 变量 - 见 liferay.com/de/web/igor.beslic/blog/-/blogs/…
    • 感谢 Jozef,将实施链接中的说明并回复您。
    【解决方案2】:

    在您的批准状态下将以下代码添加到通知中

    <recipients> <user /> </recipients>

    这会将通知发送给创建资产的用户

    【讨论】:

    • 是的,这行得通。我已经更新了我的问题。需要有关条件通知的帮助。
    • Gautham 在您的拒绝状态下添加拒绝通知,这样您就可以根据状态向用户发送两条不同的消息,并从 PendingTask 中删除 RejectedNotification 和 ApprovedNotification
    • 通知不会在&lt;states&gt; 标签中发送。为了克服这个问题,我实施了 Jozef Chocholacek 的建议。
    猜你喜欢
    • 2016-04-23
    • 2010-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多