Skip to main content

Workflow Example 1

Let create a simple workflow for document approval. Its process will look line this:

image.png

It will be started manually with either provided documents for approval or it will prompt for the documents to be used for approval. The next stem goes to a user responsible for the selected documents approvals. The next step is decision gateway - it checks if the documents are approved or not. If they are approved the flow goes to the Approved user task step, which are assigned to the approval requested user. In not, it goes to "Not Approved" user task. After the corresponding last step is completed the process end.

Follow these steps to create this workflow:

  1. We will need a custom workflow instance type and two types of workflow tasks: Workflow Approve Task and Workflow Approval Done Task.
    1. For this go to Administration/Types and search for workflow instance:
      image.png
    2. Click on it and from there execute "Create Subtype":

      image.png


    3. Name it "ApproveDocumentProcess" with display name "Approve Documents":

      image.png


    4. In the properties add existing properties Assignee, Due Date and Description:

      image.png


    5. Click the "Lens " button next to the Properties field and click "Create New" -> "Property":

      image.png


    6. Fill the following details (name: documents, count 1 or more, property type: Document):

      image.png


    7. Edit property placements to your likeness:

      image.png

      image.png


    8. Click "Create" button.
  2. Similarly create types for the two approval tasks:
    1. You will need ne properties Comments and Approved:

      image.png

      image.png


    2. The Workflow Approve Task:

      image.png


    3. Workflow Approve Done Task:

      image.png


  3. Now we are ready to create the workflow definition:
    1. From the Workflow select "Create New":

      image.png


    2. Set the properties of the process. Expand "General", fill Name and ID (must be unique in your installation) and check "Executable":

      image.png


    3. Select the start event (the only circle in the process diagram) and fill its properties. For the Form key put the name of newly created Workflow Instance's subtype "ApproveDocumentsProcess":

      image.png


    4. Create two Execution listeners for start and complete and put the corresponding inline groovy scripts to each of those:

      image.png

      The script is:
      workflowInitiatorUser = helpers.createCamundaObjectWrapper(userHelpers.getUserById(workflowInitiatorSubject, godUser), godUser)
      
      execution.setVariable('workflowInitiatorUser', workflowInitiatorUser)
      s:

      it sets variable workflowInitiator to be used in other parts of the workflow.


    5. Click on "Append Task" next to the Start event to create the next step:

      image.png


    6. Click "Change Element" and select "User Task":

      image.png

      image.png


    7. Set the properties of the step:

      image.png

      For Assignee enter: ${assignee != null ? assignee.id.toString() : null } . For Due Date enter: ${dueDate == null ? null : dueDate.toDate()}.
      image.png