Data trigger
Introduction
There are multiple ways to trigger a workflow in Casewhere. One is data trigger, which allows Casewhere to execute a workflow when data changes.
Imagine your solution must send an email every time a user is added. There are many ways to add a user, and repeating the sending email logic in all user creation workflows is never a good approach. A better one is to create a data trigger that listens to the user creation event and triggers a workflow to send an email.
In Casewhere Admin, navigate to Data Triggers. From here, you can create, edit and manage data triggers like any product resource.
Configuration
The following information is required to configure a data trigger:
Name: Name must be required and unique.
Trigger Rule: Rule to determine whether a new workflow should be triggered upon the creation, modification, or deletion of a data object. Here you can learn more about it.
Data Class: The data class the trigger runs on.
Is Synchronous: When checked, the data trigger, including the rule evaluation and workflow execution will run immediately in the same context of the workflow emitting the change event. Otherwise, the data trigger will be queued and executed in the background.
Workflow Definition: The triggered workflow definition will be run when the data object meets the trigger rules. Casewhere only accepts automatic workflow definitions for using with data triggers. The workflow definition must also accept input in order to access the changed data object.
Process: The process Casewhere executes the data trigger. If the workflow definition is case creation, a new case will be created.
Is Active: Based on this value, a trigger can run or not run. If you don't want a trigger to run, uncheck this box.
Priority: Triggers will run in order, so you should set their priority. Priority order: Urgent > As Soon As Possible > Normal > Low.
How it works
When a data object changes, Casewhere will examine all active data triggers associated with that data class and execute them in priority order. The workflow can be executed if the data object satisfies the trigger rules. Depending on the configuration, it can be run immediately or in the background.
Let's have a look at an example below:
In the workflow "Add New Book Workflow", we have 2 activities: "Add New Book" and "Confirmation Message".
"Add New Book" will show a dialog, in which a user can fill out the information for a new book.
"Confirmation Message" will show a message to confirm that adding is complete.
A trigger "New Book Trigger" will execute a workflow to update "status".
When a new book is added, the trigger will run. It executes the workflow to update the status "available".
If the "Is Synchronous" setting is checked, the trigger immediately updates the status and allows a user to view it on the form.
Otherwise, the workflow must be delayed and run in the background. Therefore, the status just shows the default value "unavailable".