Skip to content

Instantly share code, notes, and snippets.

@rodrigocunhaa
Last active February 18, 2021 21:34
Show Gist options
  • Save rodrigocunhaa/e64308da113cf432eed1180015fa3a5c to your computer and use it in GitHub Desktop.
Save rodrigocunhaa/e64308da113cf432eed1180015fa3a5c to your computer and use it in GitHub Desktop.
Two Approval Workflow
<?xml version="1.0"?>
<workflow-definition xmlns="urn:liferay.com:liferay-workflow_7.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:liferay.com:liferay-workflow_7.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_7_1_0.xsd">
<name>Two Approval Workflow</name>
<version>1</version>
<state>
<name>created</name>
<metadata>
<![CDATA[{"xy":[36,51]}]]>
</metadata>
<initial>true</initial>
<transitions>
<transition>
<name>review</name>
<target>review</target>
<default>true</default>
</transition>
</transitions>
</state>
<state>
<name>final approval</name>
<metadata>
<![CDATA[{"xy":[775,50]}]]>
</metadata>
<actions>
<action>
<name>final approval</name>
<description>
</description>
<script>
<![CDATA[import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("approved"), workflowContext);]]>
</script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
<notification>
<name>New Content</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[New content was published!]]>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<recipients receptionType="to">
<roles>
<role>
<role-type>site</role-type>
<name>Vendor</name>
<auto-create>true</auto-create>
</role>
</roles>
</recipients>
<execution-type>onEntry</execution-type>
</notification>
</actions>
</state>
<task>
<name>update</name>
<metadata>
<![CDATA[{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[40,370]}]]>
</metadata>
<actions>
<action>
<name>reject</name>
<script>
<![CDATA[import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("denied"), workflowContext);
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("pending"), workflowContext);]]>
</script>
<script-language>groovy</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>Creator Modification Notification</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[Your submission was rejected by ${userName}, please modify and resubmit.]]>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<user/>
</recipients>
<execution-type>onAssignment</execution-type>
</notification>
</actions>
<assignments>
<user/>
</assignments>
<transitions>
<transition>
<name>resubmit</name>
<target>review</target>
<default>true</default>
</transition>
</transitions>
</task>
<task>
<name>review</name>
<metadata>
<![CDATA[{"xy":[168,36]}]]>
</metadata>
<actions>
<notification>
<name>Review Notification</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[${userName} sent you a ${entryType} for review in the workflow.]]>
</template>
<template-language>freemarker</template-language>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<roles>
<role>
<role-type>site</role-type>
<name>Site Content Reviewer</name>
<auto-create>false</auto-create>
</role>
</roles>
</recipients>
<execution-type>onAssignment</execution-type>
</notification>
<notification>
<name>Review Completion Notification</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[Your submission was reviewed
<#if taskComments?has_content> and the reviewer applied the following ${taskComments}</#if>.]]>
</template>
<template-language>freemarker</template-language>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<user/>
</recipients>
<execution-type>onExit</execution-type>
</notification>
</actions>
<assignments>
<roles>
<role>
<role-type>site</role-type>
<name>Manager A</name>
<auto-create>true</auto-create>
</role>
</roles>
</assignments>
<transitions>
<transition>
<name>reject (Manager A)</name>
<target>update</target>
<default>true</default>
</transition>
<transition>
<name>approve it (Manager A)</name>
<target>next_approval</target>
<default>false</default>
</transition>
</transitions>
</task>
<task>
<name>next_approval</name>
<metadata>
<![CDATA[{"xy":[542,46]}]]>
</metadata>
<actions>
<action>
<name>next_approval</name>
<description>
</description>
<script>
<![CDATA[]]>
</script>
<script-language>groovy</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>aaa</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[you have an article to review for final review]]>
</template>
<template-language>freemarker</template-language>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<roles>
<role>
<role-type>site</role-type>
<name>Site Administrator</name>
<auto-create>false</auto-create>
</role>
</roles>
</recipients>
<execution-type>onAssignment</execution-type>
</notification>
</actions>
<assignments>
<roles>
<role>
<role-type>site</role-type>
<name>Manager B</name>
<auto-create>true</auto-create>
</role>
</roles>
</assignments>
<transitions>
<transition>
<name>reject (Manager B)</name>
<target>second_update</target>
<default>true</default>
</transition>
<transition>
<name>approve it (Manager B)</name>
<target>final approval</target>
<default>false</default>
</transition>
</transitions>
</task>
<task>
<name>second_update</name>
<metadata>
<![CDATA[{"xy":[558,353]}]]>
</metadata>
<actions>
<action>
<name>reject</name>
<description>
</description>
<script>
<![CDATA[import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("denied"), workflowContext);
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("pending"), workflowContext);]]>
</script>
<script-language>groovy</script-language>
<execution-type>onAssignment</execution-type>
</action>
<notification>
<name>check again</name>
<description>
<![CDATA[]]>
</description>
<template>
<![CDATA[check again]]>
</template>
<template-language>freemarker</template-language>
<notification-type>user-notification</notification-type>
<recipients receptionType="to">
<user/>
</recipients>
<execution-type>onAssignment</execution-type>
</notification>
</actions>
<assignments>
<user/>
</assignments>
<transitions>
<transition>
<name>resubmit</name>
<target>review</target>
<default>true</default>
</transition>
</transitions>
</task>
</workflow-definition>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment