Workflow Listeners (Completion Handlers)
Workflow Listeners, also known as Completion Handlers, are workflows that execute after another workflow has been completed. These listeners have a context variable that can be used to reference previous contexts from the workflow that was completed.
Example Workflow Use-Cases
Let's look at a few use cases for using Workflow Listeners:
Adding additional functionality to sync workflows
Taking additional steps after the onboarding workflow is complete.
You can add additional functionality to an existing synced workflow without having to unsync it from the template.
Alerting for failed workflow executions, i.e. kicking off the listener based on a failed status.
How to Access the Context of the Previous Workflow
Contexts from the previously run workflow can be accessed with the COMPLETED_WORKFLOW
variable. You can access most info via the context including ORG and CTX such as:
{{ COMPLETED_WORKFLOW.ORG.VARIABLES.cw_manage_company_id }}
{{ COMPLETED_WORKFLOW.CTX.user.username }}
Workflow listeners will always run in the context of the parent MSP. If you are taking actions on a sub-organization in the workflow then you must utilize the run-as-organization functionality and overrides set at the workflow listener level.
The organization id that was used in the previous workflow context can be referenced with the following Jinja:
{{ COMPLETED_WORKFLOW.ORG.ATTRIBUTES.id }}
How to Configure a Listener
You can configure a workflow listener one of two ways.
When this workflow completes (Creating from the workflow this is set to run from)
Open the workflow that you want the listener to run after.
Click on the Monitor icon.
Click Add at the top right.
Select the workflow you would like to run.
Select the statuses that you would like for the workflow to be triggered on.
Add the overrides for the integrations used in your listener.
Click Submit.
Make sure enabled is checked.
Run this workflow when (Creating from the listener itself)
Repeat steps 1 and 2 from above.
Repeat steps 4-9, but instead of choosing the listener workflow, you will choose the workflows that you would like the listener to execute after they complete.
Last updated