Completion handlers
Completion Handlers are workflows that execute after another workflow has been completed. These workflows 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 Completion Handlers:
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 }}
Completion Handlers 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 Completion Handler 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 Completion Handler
You can configure a Completion Handler in one of two ways.
1: When this workflow completes (Creating from the workflow this is set to run from)
Open the workflow that you want 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 Completion Handler.
Click Submit.
Make sure enabled is checked.
2: Run this workflow when (Creating from the Completion Handler itself)
Repeat steps 1 and 2 from above.
Repeat steps 4-9, but instead of choosing the Completion Handler workflow, you will choose the workflows that you would like the to execute after they complete.
Last updated
Was this helpful?