Overview | Triggers | Example | Related pages
Overview
You can use workflow triggers to help automate your documentation process and flexibly respond to workflow events.
For example, you can use a trigger to automatically send an email when a page is submitted for review.
Triggers can be added to
listen for workflow
events
check for a set condition or
conditions
to be met for each eventset one or more
actions
for each event
A custom workflow can include one or more workflow triggers
. A workflow trigger is added as JSON code using the workflow builder or the JSON editor.
Triggers
A JSON trigger
contains three different
elements:
Filter by label (Content by label) | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Multiple triggers can be added to a workflow. A trigger for an event must include at least one or more actions.
Related Pages
Child pages (Children Display) |
---|
Workflow |
---|
trigger |
---|
events |
---|
Workflow trigger conditions |
---|
Workflow trigger actions | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
You can /wiki/spaces/CDMCD/pages/614010813.
add a workflow trigger using the code editor
The code editor includes
color coding to easily distinguish property names, values, and different data types
autocomplete features
dropdown selectors for workflow trigger events, conditions, and action properties
code validation
Or add the trigger JSON code directly to your workflow using the visual editor.
You can toggle between the code editor and the visual editor. Changes made in one editor are automatically updated in the other editor.
Example
In a 4-state workflow, you might want the workflow to move immediately from a Rejected state to a more proactively named Triage state rather than waiting for a user to manually transition the content.
You can use a trigger to listen for the state change event to the Rejected state and set the trigger action to immediately transition to the Triage state.
The trigger is created using JSON code.
Code Block |
---|
"triggers": [ {"event":"on-change-state", "conditions": [ {"state":"Rejected"} ], "actions": [ {"action":"change-state", "state":"Triage"} ]} ] |
Info |
---|
If you want to add this trigger to a workflow using the workflow builder visual editor, copy and paste the JSON code format (without the opening |
There are a number of workflow events that can be added to a trigger. For each trigger, you can set one or more conditions, for example, to constrain a trigger to listen for an event that occurs in a particular state. One or more actions can be added to a workflow trigger that are undertaken when the event takes placeoccurs.
Each trigger action can have a number of mandatory elements parameters and optional elements parameters depending on the action.
Related pages
hiddenTriggerstrue
Child pages (Children Display) |
---|
Code Block |
---|
"triggers":
[
{
"event":"on-change-state",
"conditions":[
{
"final":true
}
],
"actions":[
{
"action":"publish-page"
},
{
"action":"send-email",
"recipients":[
"@document_user_reviewers@",
"@document_group_reviewers@"
],
"notification":{
"subject":"${content.title} is in Review State",
"title":"${content.title} is in Review State",
"body":"Hello, ${content.link} in the ${content.space} space needs to be reviewed"
}
}
]
}
] |
If adding the JSON trigger using workflow builder there is no need to include the opening "triggers”: JSON markup notation, since it will be added by workflow builder.
The example above has one trigger, the trigger uses a generic event - a state change event - but the added condition sets the trigger to only listen for the state change event to the final state in the workflow.
Trigger One
Trigger event
WHEN the document changes state
"event":"on-change-state"
Trigger condition for the event
AND the new state is the final state
"conditions":[ { "final":true } ]
Trigger action†
THEN the page is published to a new space*
"actions":[ { "action":"publish-page" }, ...
Trigger action†
AND an email is sent
... { "action":"send-email", "recipients":[ "@document_user_reviewers@", "@document_group_reviewers@" ], "notification":{ "subject":"${content.title} is in Review State", "title":"${content.title} is in Review State", "body":"Hello, ${content.link} in the ${content.space} space needs to be reviewed" }}]
* This publishing action using "publish-page"
is only available when the Comala Publishing for Cloud app is installed and the current space has been enabled as a draft space for publishing to target public space.
† Multiple trigger actions are added as a comma-separated list, each action enclosed in curly "{" brackets. The list of actions is then enclosed in square brackets e.g. "actions":[{"action":"action1"}, { "action": "action2"}]
A trigger contains three different properties.
Table of Contents | ||||
---|---|---|---|---|
|
Events
The event name the trigger will listen for. These include:
"on-change-state"
"on-approve"
"on-reject"
"on-assign"
"on-unassign"
"on-expire"
When creating a workflow JSON trigger
you can add multiple
event
s to a JSON"trigger"
you can only use each
event
type once in a JSON"trigger"
Conditions
One or more conditions that must be met for the trigger to perform the specified action(s) for an event.
"state": "(string value)"
"initial": (boolean true/false)
"final":(boolean true/false)
Code Block |
---|
"conditions":[{"state": "Review"}] |
You can add more than one different condition in a comma separated bracketed list.
The following is evaluated as an AND condition when using "initial"
and "state"
conditions.
Code Block |
---|
"conditions":[{"state": "Review" },{"initial":true}] |
The following is evaluated as an OR condition when using "final"
and "state"
conditions.
Code Block |
---|
"conditions":[{"state": "Review" },{"final":true}] |
comma-separated list of conditions are enclosed in square brackets
each individual condition is enclosed in a set of curly brackets
For "state"
condition only one state name value can be entered. Multiple state name values are not accepted.
Actions
A list of actions to perform once the event has occurred and the conditions are fulfilled. These actions include
Filter by label (Content by label) | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
Code Block |
---|
"actions":[{"action":"change-state","state":"Review"}] |
There are two elements that must be present for the change-state action
define the action using [{"action":"change-state", ...
..."state":"Review"}]
Using Workflow Builder