Workflow

Development

Kubernetes

(November 2019) We are trying to use Kubernetes for Development - Install for local development with Flowable on our workstations.

Here are a couple of links to .env and settings files:

Manual

Form Fields

Check Box

_images/workflow-form-field-check-box.png

To create a series of tick boxes, the type must be boolean:

<activiti:formProperty id="monday" name="Monday" type="boolean" expression="True"></activiti:formProperty>
<activiti:formProperty id="tuesday" name="Tuesday" type="boolean" expression="True"></activiti:formProperty>
<activiti:formProperty id="wednesday" name="Wednesday" type="boolean" expression="True"></activiti:formProperty>

Form Headings

_images/workflow-form-headings.png

To create a form heading, add a formProperty with _heading appended to the id e.g:

<activiti:formProperty id="invoice_heading" name="Invoice Heading" type="string" required="true" writable="false">

The name will display as the heading.

You can add help text in Settings, Mapping, Mapping, <field name>, Help Text.

Note:

  • writable must be false

  • The property must not have a value (not sure where this comes from)

  • If the name is empty, you must add help text.

HTTP Task

Add the apiUrl to the start event. The requestUrl will use this variable as follows:

${apiUrl}/refresh-variables/${execution.getProcessInstanceId()}/

See this ticket for an example API and a test workflow: https://www.kbsoftware.co.uk/crm/ticket/4974/

Tip

If you are running Flowable inside Kubernetes, then make sure your apiUrl is accessible from there.

Tip

This is a very useful forum post to help with variables in the HTTP task: How should I use PUT/POST in Http task when I am limited to only strings

Options

dataDocument

Attach a simple PDF document with a table containing the form variables.

To get it working, add a form variable with an id of dataDocument. The name will be used as the title e.g: <activiti:formProperty id="dataDocument" name="My Data Document" type="string"></activiti:formProperty>

copyToDocumentManagement

Copy attachments to Alfresco:

<activiti:formProperty id="copyToDocumentManagement" name="Copy Attachments to Share" type="boolean" expression="True"></activiti:formProperty>

deleteWorkflow

Will add a Delete Workflow button to the task.

This is useful when the workflow is in development as the process can be deleted quickly and easily.

Prerequisite

Every task must have the following form variable:

auditDescription

The text in the Expression will be added to the audit for this process.

Script Task

From JSON process variables - any gotchas?, to save data in json format:

<scriptTask id="sid-780D1BD8-9E03-4802-8EC3-C944F5B00A67" scriptFormat="javascript" flowable:autoStoreVariables="false">
  <script>
    <![CDATA[var ObjectMapper = com.fasterxml.jackson.databind.ObjectMapper;
      var data = {};
      data.name = "Andrea";
      var httpTaskData = JSON.stringify(data);
      var json = new ObjectMapper().readTree(httpTaskData);
      execution.setVariable("httpTaskData", json);]]>
  </script>
</scriptTask>

Tip

Make sure the scriptFormat is set to javascript.

Management Commands

create_pending_workflows

Warning

Please test this carefully before running on a live site.

Will check the database for workflows which haven’t been created and then create them.

Settings

Activiti

A standard install will have Flowable running on localhost. To configure this, add the following settings:

# 'settings/base.py'
ACTIVITI_HOST = 'localhost'
ACTIVITI_PORT = 8080

# 'settings/local.py'
ACTIVITI_PATH = 'activiti-rest'

# 'settings/production.py'
ACTIVITI_PATH = 'activiti-rest-{}'.format(DOMAIN.replace('.', '-').replace('-', '_'))

If Flowable is running on a different server, you can configure the settings differently e.g:

# 'settings/base.py'
ACTIVITI_PORT = 8080

# 'settings/local.py'
ACTIVITI_HOST = 'localhost'
ACTIVITI_PATH = 'activiti-rest'

# 'settings/production.py'
ACTIVITI_HOST = get_env_variable("ACTIVITI_HOST")
ACTIVITI_PATH = 'activiti-rest-{}'.format(DOMAIN.replace('.', '-').replace('-', '_'))

workflow app

The URL for an API should be added to WORKFLOW_API_URL. We also have a WORKFLOW_PLUGIN system which can be used to add extra variables to a workflow e.g:

WORKFLOW_API_URL = get_env_variable("WORKFLOW_API_URL")
WORKFLOW_PLUGIN = ("example_workflow.models.WorkflowContact",)

Add the WORKFLOW_API_URL to the pillar file for your project.

Warning

Do not append a / to the end of the WORKFLOW_API_URL e.g. http://127.0.0.1:3042/api/0.1

Settings (Dashboard)

History

Settings, Workflow, Tasks has a new History menu option which allows you to filter by workflow type e.g.

_images/app-workflow-settings-history.png

Task History

Settings, Workflow, Tasks and clicking on a process, gives you access to Task History:

_images/app-workflow-settings-task-history.png

Delete a Task by ID

from workflow.activiti import Activiti
activiti = Activiti()
# replace `17077`` with your task ID
task = activiti.task_status(17077)
task.process_key
activiti.process_delete(task.process_id)