Overview

One or more conditions can be set for a trigger for a named event in the workflow. When the named workflow event occurs the trigger will check that any required condition is met, and if met set one or more actions.

Conditions

A condition must be met for the trigger to perform the specified action(s). Available conditions are

  • "state": "(string value)"

  • "initial": (boolean true/false)

  • "final":(boolean true/false)

JSON ConditionJSON CodeNote

"state": "(string value)"

"conditions":
[
	{"state": "Review"}
],

The trigger action will occur if the condition matches the provided state.

  • specified state name must exist in the current workflow
  • only one state can be specified
  • only one "state": "statename" can be added as a condition for each event

For state condition only one state name value can be entered. Multiple state name values are not accepted.

"final": (boolean true/false)

"conditions":
[
	{"final":true}
],

The trigger action will occur if the state for the event is the final state.

For example, 

  • "event":"on-change-state", "conditions":[{"final":true}],"actions":[{"action": "clean-messages"}]

This on-change-state event condition is met on the the change to the final state in the workflow.

The final parameter value is boolean

  • "final":true
  • "final":false

If final condition is added together with another condition within the same trigger, then those conditions are evaluated as an OR function.

"initial":(boolean true/false)

"conditions":
[
	{"initial":true}
],

The trigger action will occur if the state for the event is the initial state in the workflow.

The initial parameter value is boolean

  • "initial":true
  • "initial":false

You can add more than one different condition in a comma separated bracketed list.

  • comma-separated list of conditions are enclosed in square brackets
  • each individual condition is enclosed in a set of curly brackets

When adding more than one condition under the same trigger, those are evaluated as an AND function, unless one of them is the final condition, in which case they are evaluated as an OR function. Example:

  • The following is evaluated as an AND condition when using initial and state conditions.

"conditions":[{"state": "Review" },{"initial":true}]

  • The following is evaluated as an OR condition when using final and state conditions.

"conditions":[{"state": "Review" },{"final":true}]

Example on-change-state event


"triggers":
[
    {"event": "on-change-state",
    "conditions":
    [
        {"initial":true},{"final":true}
    ],
    "actions":
    [
        {"action": "clean-messages"}
    ]}
]

(info) 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 trigger action will clear any existing messages on the content

  • "actions":[{ "action":"clean-messages"}],

The action will occur on the change of state event if the current state is either the initial state OR the final state in your workflow.

  • "conditions":[{"initial":true},{"final":true}],

If a JSON condition is present this can include one or more conditions. The trigger will only allow the event to be valid if these conditions are valid.


Example on-approve event


"triggers":
[
	{"event": "on-approve",
	"conditions":
	[
		{"state":"Review"}
	],
	"actions":
	[
		{"action":"change-state",
			"state":"Published"}
	]}
]

(info) 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 trigger action will cause a change of state

  • "actions":[{ "action":"change-state"}],

The trigger action will occur on the approve event but ONLY if the current state is the Review state

  • "conditions":[{"state":"Review"}],

If a JSON condition is present this can include one or more conditions. The trigger will only allow the event to be valid if these conditions are valid.