In Campaign Standard, the workflow engine guarantees that a workflow instance is executed by only one process. Blocking activities such as imports, long running queries or writes into the database prevent the execution of any other task when running.
On the other hand, non-blocking activities do not block the execution of other tasks (usually activities waiting for an event such as the Scheduler activity).
This can lead to a scenario where a schedule-based workflow can start executing even when the previous run of that same workflow has not yet finished, potentially leading to unexpected data issues.
Therefore, when designing a scheduled workflow which includes multiple activities, you need to make sure that the workflow is not rescheduled until it is finished. To do this, you need to configure your workflow in order to prevent its execution if one or more tasks from a previously execution is still pending.
To check if one or more tasks from a previous workflow execution is still pending, you need to use a Query and a Test activity.
Add a Query activity after the Scheduler activity, then configure it as follows.
Change the activity’s resource to WorkflowTaskDetail, meaning it will target the workflow’s current tasks.
Configure the query with the rules below:
The first rule filters out the current task (query2) as well as the next schedule task (schedule2) belonging to the current workflow.
When a Scheduler activity starts, it immediately adds another schedule task to run at the next scheduled time and start the workflow. Therefore, it is important to filter both the query as well as schedule tasks when looking for pending tasks from a previous execution.
The second rule determines whether any tasks from a previous run of the workflow are still active (pending), which corresponds to the 0 execution status.
Add a Test activity in order to check for the number of pending tasks returned by the Query activity. To do this, configure two outbound transitions.
You can now configure the rest of your workflow as needed. If the workflow execution is canceled due to pending tasks, when the workflow runs again as per the schedule, it can go through these steps. This will ensure that the workflow execution will proceed only if there are no active (pending) tasks from a previous execution.