Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Two level or multilevel workflow for Liferay 6.2

    • 0
    • 1
    • 0
    • 0
    • 5
    • 0
    • 0
    • 0
    • 1.95k
    Comment on it

    Hello guys, many times developers got stuck into the issue that How to create Two level or multilevel workflow for Liferay 6.2. So here below I have created two level or multilevel workflow for liferay 6.2. In which first approver approve the task after that second approver can approve. Copy all code and save in XML file.

    <?xml version="1.0"?>
    <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>Two_Level_Approver</name>
    <description>A approver can approve a workflow content.</description>
    <version>1</version>
    <state>
    <name>created</name>
    <metadata>
    <![CDATA[{"xy":[36,51]}]]>
    </metadata>
    <initial>true</initial>
    <transitions>
    <transition>
    <name>FirstApproval</name>
    <target>FirstApproval</target>
    </transition>
    
    </transitions>
    </state>
    
    <!--  First Reject -->
    
    <task>
    <name>FirstReject</name>
    <metadata>
    <![CDATA[{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}]]>
    </metadata>
    <actions>
    <action>
    <name>reject</name>
    <script>
    <![CDATA[
    Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), workflowContext);
    Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("incomplete"), workflowContext);
    ]]>
    </script>
    <script-language>javascript</script-language>
    <execution-type>onAssignment</execution-type>
    </action>
    <notification>
    <name>Creator Modification Notification</name>
    <description>Permit Issuer : First Approval Rejected</description>
    <template>Your submission was rejected in First Approval by ${userName}, please modify and resubmit.</template>
    <template-language>freemarker</template-language>
    <notification-type>email</notification-type>
    <notification-type>user-notification</notification-type>
    <execution-type>onAssignment</execution-type>
    </notification>
    </actions>
    <assignments>
    <roles>
    <role>
    <role-type>site</role-type>
    <name>Site Administrator</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Owner</name>
    </role>
    </roles>
    </assignments>
    <transitions>
    <transition>
    <name>resubmit</name>
    <target>FirstApproval</target>
    </transition>
    
    </transitions>
    </task>
    
    <!-- FirstApproval -->
    <task>
    <name>FirstApproval</name>
    <metadata>
    <![CDATA["xy":[40,62]}]]>
    </metadata>
    <actions>
    <action>
    <name>FirstApproval</name>
    <script>
    <![CDATA[
    workflowContext.put("notificationSenderName", "Permit Issuer");
    ]]>
    </script>
    <script-language>groovy</script-language>
    <execution-type>onEntry</execution-type>
    </action>
    <notification>
             <name>Case Submission</name>
         <description>Permit Issuer: Case Submission Notification</description>
             <template>
              Your Case has been submitted with following Case Number: 23434, you can check the status of your case using this case number.
              </template>
             <template-language>freemarker</template-language>
             <notification-type>email</notification-type>
             <recipients>
              <user />
             </recipients>
             <execution-type>onAssignment</execution-type>
    </notification>
    <notification>
        <name>First Review Notification</name>
        <description>Permit Issuer: New Permit Request</description>
        <template>We got a new Permit Request,  Please review the request.</template>
        <template-language>freemarker</template-language>
        <notification-type>email</notification-type>
        <notification-type>user-notification</notification-type>
        <execution-type>onAssignment</execution-type>
    </notification>
    
    
    
    <notification>
        <name>First Review Completion Notification</name>
        <description>Permit Issuer: First Approval Completed</description>
        <template>First Approval Status: 
        Your submission has been Approved at First Approval by ${userName} with following comments [${taskComments}]. Request has been sent for Second Approval. </template>
        <template-language>freemarker</template-language>
        <notification-type>email</notification-type>
        <recipients>
        <user />
        </recipients>
        <execution-type>onExit</execution-type>
    </notification>
    
    </actions>
    <assignments>
    <roles>
    <role>
    <role-type>organization</role-type>
    <name>Organization Administrator</name>
    </role>
    <role>
    <role-type>organization</role-type>
    <name>Organization Content Reviewer</name>
    </role>
    <role>
    <role-type>organization</role-type>
    <name>Organization Owner</name>
    </role>
    <role>
    <role-type>regular</role-type>
    <name>Administrator</name>
    </role>
    <role>
    <role-type>regular</role-type>
    <name>Portal Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Administrator</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Owner</name>
    </role>
    </roles>
    </assignments>
    <transitions>
    <transition>
    <name>approve</name>
    <target>Firstapproved</target>
    </transition>
    
    <transition>
    <name>reject</name>
    <target>FirstReject</target>
    <default>false</default>
    </transition>
    </transitions>
    </task>
    
    <!-- Second Reject -->
    
    <task>
    <name>SecondReject</name>
    <metadata>
    <![CDATA[{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}]]>
    </metadata>
    <actions>
    <action>
    <name>reject</name>
    <script>
    <![CDATA[
    Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), workflowContext);
    Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("incomplete"), workflowContext);
    ]]>
    </script>
    <script-language>javascript</script-language>
    <execution-type>onAssignment</execution-type>
    </action>
    <notification>
    <name>Creator Modification Notification</name>
    <description>Permit Issuer: Second Approval Rejected</description>
    <template>Your submission was rejected at Second Approval by ${userName} with following comments [${taskComments}], please modify and resubmit.</template>
    <template-language>freemarker</template-language>
    <notification-type>email</notification-type>
    <notification-type>user-notification</notification-type>
    <execution-type>onAssignment</execution-type>
    </notification>
    </actions>
    <assignments>
    <roles>
    <role>
    <role-type>site</role-type>
    <name>Site Administrator</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Owner</name>
    </role>
    </roles>
    </assignments>
    <transitions>
    <transition>
    <name>resubmit</name>
    <target>FirstApproval</target>
    </transition>
    
    </transitions>
    </task>
    
    <!-- SecondApproval -->
    
    <task>
    <name>SecondApproval</name>
    <metadata>
    <![CDATA[{"xy":[168,36]}]]>
    </metadata>
    
    <actions>
    
    <notification>
    <name>Second Review Notification</name>
    <description>Permit Issuer: Second Approval Request</description>
    <template>${userName} sent you request for Second review.</template>
    <template-language>freemarker</template-language>
    <notification-type>email</notification-type>
    <notification-type>user-notification</notification-type>
    <execution-type>onAssignment</execution-type>
    </notification>
    <notification>
    <name>Second Review Completion Notification</name>
    <description>Permit Issuer: Second Approval Completed</description>
    <template>
    Your submission has been Approved at Second Approver by ${userName} with following comment ${taskComments}.</template>
    <template-language>freemarker</template-language>
    <notification-type>email</notification-type>
    <recipients>
    <user />
    </recipients>
    <execution-type>onExit</execution-type>
    </notification>
    </actions>
    <assignments>
    <roles>
    <role>
    <role-type>organization</role-type>
    <name>Organization Administrator</name>
    </role>
    <role>
    <role-type>organization</role-type>
    <name>Organization Content Reviewer</name>
    </role>
    <role>
    <role-type>organization</role-type>
    <name>Organization Owner</name>
    </role>
    <role>
    <role-type>regular</role-type>
    <name>Administrator</name>
    </role>
    <role>
    <role-type>regular</role-type>
    <name>Portal Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Administrator</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Content Reviewer</name>
    </role>
    <role>
    <role-type>site</role-type>
    <name>Site Owner</name>
    </role>
    </roles>
    </assignments>
    <transitions>
    <transition>
    <name>approve</name>
    <target>approved</target>
    </transition>
    <transition>
    <name>reject</name>
    <target>SecondReject</target>
    <default>false</default>
    </transition>
    </transitions>
    </task>
    
    
    
    
    
    <state>
    <name>Firstapproved</name>
    <metadata>
    <![CDATA[
    {"xy":[380,51]}
    ]]>
    </metadata>
    <actions>
    <action>
    <name>approve</name>
    <script>
    <![CDATA[
    import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
    import com.liferay.portal.kernel.workflow.WorkflowConstants;
    WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.toStatus("inactive"), workflowContext);
    ]]>
    </script>
    <script-language>groovy</script-language>
    <execution-type>onEntry</execution-type>
    </action>
    </actions>
    <transitions>
    <transition>
    <name>SecondApproval</name>
    <target>SecondApproval</target>
    <default>true</default>
    </transition>
    </transitions>
    </state>
    
    
    
    <state>
    <name>approved</name>
    <metadata>
    <![CDATA[
    {"xy":[380,51]}
    ]]>
    </metadata>
    <actions>
    <action>
    <name>approve</name>
    <script>
    <![CDATA[
    import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil;
    import com.liferay.portal.kernel.workflow.WorkflowConstants;
    WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.toStatus("approved"), workflowContext);
    ]]>
    </script>
    <script-language>groovy</script-language>
    <execution-type>onEntry</execution-type>
    </action>
    </actions>
    </state>
    </workflow-definition>
    

    You can download two level workflow XML from attachment.

 5 Comment(s)

  • Hello,

    Can you please clear my one doubt regarding Kaleo workflow.

    Is it neccessary that the Kaleo workflow will always pass through admin and admin will always have the right to assign it to someone else or to self? I'm producing the test cases of what is happening with my workflow and what I actually want:
    I have the following roles:

    1. Admin-Test
    2. First approver-Approver1
    3. Second Approver-Approver2
    4. User-test333



    Now my workflow is passing like this:
    User->Approver1->Approver2(If I do not open Admin with my credentials of TEST)
    Otherwise:
    User->Admin->When Assigned to Approver1->Approver1->Approver2
    ->When Assigned to me->Admin only becomes both Approver1 and Approver2 and is approving or rejecting the same.

    I don't want the second case to happen and it should follow only the first test Case: User->Approver1->Approver2
    Admin should not have the right to approve or reject. Is it possible somehow?

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: