For enhanced customization, Dawiso allows you to define your own custom assets. These assets enable you to tailor your application to meet specific requirements beyond the standard core configurations. For a comprehensive list of all available assets, see this article.

In this tutorial, we will focus on workflow states and workflows, the most commonly used custom assets.

Workflow States and Workflows

For custom workflows in Dawiso, you need to define two assets: workflow states and workflows.

  • Workflow states define the stages an object can go through.
  • Workflows manage the transitions between those states.

Example: Recipe Manager Workflow

Since we planned the workflow during the conceptual stage, it is already prepared for our example application. In this article, we will take a look at how it needs to be configured in the package.

The diagram shows us the following:

  • Workflow states in boxes
  • Workflow transitions as arrows
  • Which user relation types can trigger which transitions

In Dawiso, workflow states appear on object pages unless specified otherwise. For more information on hiding functionalities, see Template Settings in 5.B Configure Object Type Templates.

Workflow States

The workflowStates asset defines each stage of an object’s lifecycle. Here is a blank template for defining a workflow state:

"workflowStates": [
    {
        "key": "",
        "name": "",
        "colorKey": "",
        "iconKey": "",
        "userRelationTypeKeys": []
    }
],

Let’s take a closer look at the properties:

PropertyPurpose
keyA unique identifier of the workflow state used in Workflows (to specify transitions) and Object types (to specify the state that new objects of the type start in).
nameThe display name of the workflow state in the UI.
colorKeyKey of the workflow state’s color, defined in the colors asset or by referencing a core color (Settings > Configuration > Colors).
iconKey of the workflow state’s icon, defined in the icons asset or by referencing a core icon (Settings > Configuration > Icons).
userRelationType(Optional) Key of user relation types. This property determines which users can interact with an object in this state.

Example: Recipe Manager Workflow States

Click here to show the example.
"objectTypes": [
    {
        "key": "cuisine",
        ...
        "initialWorkflowStateKey": "none",
        ...
    },
    ...
    {
        "key": "ingredient_category",
        ...
        "initialWorkflowStateKey": "none",
        ...
    },
    ...
],
...
"workflowStates": [
    {
        "key": "none",
        "name": "None",
        "colorKey": "core_approved",
        "iconKey": "core_done",
        "userRelationTypeKeys": [ ]
    },
    {
        "key": "working_on",
        "name": "Working on",
        "colorKey": "core_empty",
        "iconKey": "core_draft",
        "userRelationTypeKeys": [ ]
    },
    {
        "key": "approved",
        "name": "Approved",
        "colorKey": "core_approved",
        "iconKey": "core_done",
        "userRelationTypeKeys": [
            "recipe_owner"
        ]
    },
    {
        "key": "discarded",
        "name": "Discarded",
        "colorKey": "core_rejected",
        "iconKey": "core_canceled",
        "userRelationTypeKeys": [
            "core_admin"
        ]
    }
]
Warning

The cuisine and ingredient_category object types set initialWorkflowStateKey to none. This only works if none is part of the space application’s workflow, as its initStateKey or as a state on one of its transitions.

The recipe_manager_workflow has no transition to or from none, and its initStateKey is working_on. So in a space application using this workflow, new cuisines and ingredient categories start in working_on instead. For the full rule, see objectTypes.

Workflows

The workflows asset defines how objects transition between workflow states. Below is a blank template for a workflow:

"workflows": [
    {
        "key": "",
        "name": "",
        "diagramContent": "",
        "diagramContentType": "image/png",
        "initStateKey": "",
        "transitions": [
            {
                "fromStateKey": "",
                "toStateKey": "",
                "userRelationTypeKeys": [ ],
                "changeThresholdTypeKey": ""
            }
        ]
    }
],

The properties are used in the following way:

PropertyPurpose
keyThe workflow’s unique key.
nameThe display name in Dawiso’s UI when selecting a workflow.
diagramContentA Base64-encoded image of the workflow diagram. Convert your diagram to Base64 and provide the encoded value here.
diagramContentTypeThe image format for the diagram. Supported MIME types are: image/png, image/jpeg, image/svg+xml
initStateKeyThe key of the workflow state that new objects start in. An object type can start in a different state through its initialWorkflowStateKey, but only in a state that is part of this workflow: the initStateKey or a state on one of its transitions.
transitionsDefines all allowed state transitions. See supported transitions properties.

transitions properties

  • fromStateKey: The starting workflow state.
  • toStateKey: The target workflow state.
  • name: Name of the transition used in the UI.
  • userRelationTypeKeys: (Optional) Specifies which users can trigger the transition.
  • changeThresholdTypeKey: (Optional) Sets how many and which users must approve the transition.

Example: Recipe Manager App Workflows

The Recipe Management application uses the following workflow diagram, which shows the allowed transitions between workflow states and the associated restrictions.

Here’s how the transitions are implemented:

Click here to show the example.
"workflows": [
    {
        "key": "recipe_manager_workflow",
        "name": "Recipe Manager Workflow",
        "initStateKey": "working_on",
        "diagramContentType": "image/png",
        "diagramContent": "[download the example package for the workflow diagram in Base64]",
        "transitions": [
            {
                "fromStateKey": "working_on",
                "toStateKey": "approved",
                "name": "Approved",
                "changeThresholdTypeKey": "all_users_all_from_groups",
                "userRelationTypeKeys": [
                    "recipe_owner"
                ]
            },
            {
                "fromStateKey": "working_on",
                "toStateKey": "discarded",
                "name": "Discarded"
            },
            {
                "fromStateKey": "approved",
                "toStateKey": "discarded",
                "name": "Discarded",
                "changeThresholdTypeKey": "all_users_all_from_groups",
                "userRelationTypeKeys": [
                    "best_cook"
                ]
            },
            {
                "fromStateKey": "approved",
                "toStateKey": "working_on",
                "name": "Review",
                "userRelationTypeKeys": [
                    "recipe_owner",
                    "best_cook"
                ]
            },
            {
                "fromStateKey": "discarded",
                "toStateKey": "working_on",
                "name": "Review",
                "changeThresholdTypeKey": "one_user",
                "userRelationTypeKeys": [
                    "recipe_owner",
                    "best_cook"
                ]
            }
        ]
    }
]