CheckLoopCount

You can use the CheckLoopCount function for looping or repeating action steps during a workflow in Optiva. It tracks how many times a workflow has looped back to a previous action.

You can use the CheckLoopCountwith its return code 811 to repeat actions in a workflow for a specified number of times or until an accurate response is received.

Note: 
  • This is most appropriate for the Return event.
  • The CheckLoopCount function only supports backward loops to previous actions.

When to use

You can use this function to:

  • Review cycles that require workflows to return to previous steps for corrections, with a maximum number of iterations before escalation or cancellation.
  • Quality checks or validation that must be repeated until specified criteria are met.
  • The approvers can return workflows for revisions multiple times before final approval or rejection.

When not to use

You cannot use this function for forward workflow movement.

Syntax

int CheckLoopCount();

Return Value

The number of times the workflow has looped through the current action is returned.

Return Code

Return Code Action Description
811 Loop back The action specified in the "Loop Line" column is returned.
111 Continue The next action in the workflow is continued.
91111 Cancel The workflow is cancelled.
0/1 No action Stays at the current step.

811: You can return this code to indicate the workflow should loop back to the specified "Loop Line".

Prerequisites

  • If you skip a task within a looping group, the task remains in a skipped state.
  • There are no restrictions on branched or nested steps.

Configuration

On the Action Set form, specify the "Loop Line" column to indicate the previous action line to which the workflow should loop.

Note: 
  • You can specify any previous line as the "Loop Line", regardless of the complexity of the action set.
  • An action set can contain multiple loops.
  • You can loop backward, but not forward.
  • You must include only one loop per action.

Examples

Example 1:
Basic Loop with Maximum Count.
Description:
Allow the lab manager to "Return" a workflow to the Technical Director up to three times. On the 4th Return the workflow is cancelled.
Configuration Steps (Action Set form):
  1. Open the Action Set form for the workflow.
  2. Identify the action line which contains the CheckLoopCount function (in this example, it is Line ID 2).
  3. In that action line:
    1. Set the "Loop Line" (destination) column to the Line ID of the Technical Director action (for example, set Loop Line = 1).
    2. This instructs the workflow engine to jump to Line ID 1 when the script returns the loop/return code.
using System;
using Formation.Shared.Defs;

class ActionScript : FcProcFuncSetEventWF
{
    public long wf_start()
    {
        int iLoopcount = CheckLoopCount();

        if (iLoopcount <= 3)
        {
            MessageList("Returning to the technical director.");
            return 811L;
        }
        else
        {
            MessageList("Workflow cancelled.");
            return 9111L;
        }
    }
}