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 workflow transitions.
- 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:
| Property | Purpose |
|---|---|
key | A unique identifier of the workflow state used in:Workflows: To specify transitions., Object types: To specify the initial state of an object if there is one. |
name | The display name of the workflow state in the UI. |
colorKey | Key of the workflow state’s color, defined in the colors asset or by referencing a core color (Settings > Configuration > Colors). |
icon | Key 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 hide example.
”objectTypes”: [
{
“key”: “cuisine”,
…
“initialWorkflowStateKey”: “none”,
…
},
…
{
“key”: “ingredient_category”,
…
“initialWorkflowStateKey”: “none”,
…
},
…
],
…
“workflowStates”: [
{
“key”: “none”,
“name”: “None”,
“colorKey”: “core_status_approved”,
“iconKey”: “core_done”,
“userRelationTypeKeys”: [ ]
},
{
“key”: “working_on”,
“name”: “Working on”,
“colorKey”: “core_status_empty”,
“iconKey”: “core_draft”,
“userRelationTypeKeys”: [ ]
},
{
“key”: “approved”,
“name”: “Approved”,
“colorKey”: “core_status_approved”,
“iconKey”: “core_done”,
“userRelationTypeKeys”: [
“recipe_owner”
},
{
"key": "discarded",
"name": "Discarded",
"colorKey": "core_status_rejected",
"iconKey": "core_canceled",
"userRelationTypeKeys": [
"core_admin"
}
],
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:
| Property | Purpose |
|---|---|
key | The workflow’s unique key. |
name | The display name in Dawiso’s UI when selecting a workflow. |
diagramContent | A Base64-encoded image of the workflow diagram. Convert your diagram to Base64 and provide the encoded value here. |
diagramContentType | The image format for the diagram. Supported MIME types are: image/png, image/jpeg, image/svg+xml |
initStateKey | The key of the initial workflow state of a newly created object. Different initial workflow states can be specified for different object types. |
transitions | Defines all allowed state transitions: 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
Click here to hide example.For the Recipe Management application, we created the following workflow diagram. This diagram visually represents the allowed transitions between workflow states and the associated restrictions.
Let’s see how the transitions were implemented below:
"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"
}
}
],