Workflow Navigation

Workflow navigation provides the ability to define a set of pages and assistants which can be shown within "related pages" and can be navigated across much like assistant pages using the header buttons provided in the client app.

Workflow Header

The workflow keyword should be defined within a page. A page may include multiple workflows.

Example:

page WorkOrderDetail using WorkOrders {
     ...
     workflow StartWorkOrderWorkflow;
     workflow CompleteWorkOrderWorkflow;
     ...
}

The identifier after the workflow keyword should refer to a workflow defined in the *.client file. A workflow definition may contain the following items within it.

A step definition is used to specify the properties of each step. If the dynamic set-up function is not defined, then the client will show all the steps defined in the workflow in the same order. If a dynamic set-up function is specified, then it will be executed to get which steps in the workflow are available for the current record and the sequence.

A step definition may contain the following items within it. Each step should be named.

The dynamic set-up function may accept any number of parameters and should return a list of structure type FndWorkflowStep. This structure has an attribute called Name which can be set to one of the step names defined in the workflow. The attribute called Sequence should be used to define the order of the steps and also acts as a unique identifier.

An example workflow in the *.client file is given below:

Client:

workflow WorkOrderWorkflow for TstOffWorkOrder {
   init command {
      label = "Start Workflow";
      execute {
         alert("Starting completion process of work order...");
      }
   }

   dynamic GenerateWorkflowSteps(WoNo);

   steps {
      step TimeReportsStep {
         label = "Time Report";
         icon = "clock";
         emphasis Complementary6 = [true];
         navigate WorkOrderTimeReportsPage(WoNo);

         next command {
            variable Result1;
            variable ConfirmResult;
            execute {
               call IsWorkflowStepValid(WoNo, "TimeReportsStep") into Result1;

               if [Result1 = true] {
                  confirm("Do you really want to move to the next step?") {
                     when OK {
                        exit OK;
                     }
                  }
               }
            }
         }
      }

      step LineChartStep {
         label = "Line Chart";
         icon = "line-chart";
         emphasis Complementary9 = [true];
         navigate LineChartDataPage(WoNo);
      }

      step FinishWoAssistantStep {
         label = "Finish WO";
         navigate FinishWoAssistant;
      }
   }

   finish command {
      label = "Finalize";
      icon = "direction";

      execute {
         alert("Done");
         navigate back;
      }
   }
}

Projection:

function GenerateWorkflowSteps List<Structure(FndWorkflowStep)> {
    parameter WoNo Number;
}

function IsWorkflowStepValid Boolean {
    parameter WoNo Number;
    parameter WorkflowStepName Text;
}

Offline file:

@Overtake Core
procedure Function<GenerateWorkflowSteps> List<Structure(FndWorkflowStep)> {
    parameter WoNo Number;
    variable StepsList List<Structure(FndWorkflowStep)>;
    variable Step Structure(FndWorkflowStep);
    execute {
        create Step;
        set Step.Sequence = 1;
        set Step.Name = "LineChartStep";
        call List.Add(StepsList, Step);

        create Step;
        set Step.Sequence = 2;
        set Step.Name = "TimeReportsStep";
        call List.Add(StepsList, Step);

        create Step;
        set Step.Sequence = 3;
        set Step.Name = "FinishWoAssistantStep";
        call List.Add(StepsList, Step);

        return StepsList;
    }
}

@Overtake Core
procedure Function<IsWorkflowStepValid> Boolean {
    parameter WoNo Number;
    parameter WorkflowStepName Text;
    execute {
        return true;
    }
}

In this example, you can observe:

When all the steps are returned from the dynamic set-up function and they are added to the list of related pages, they will appear in the order in the below image (screenshot shown from the Windows client, the appearance of any items depicted may be subject to change).

Workflow Related Pages

As you have your workflow defined above, you can use a command to navigate to a specific step in your workflow. This can be specified as the step name, or the sequence number.

Client:

command GoToWorkflowStep {
   label = "Work flow step 2";
   enabled = [true];
   execute {
      navigate {
         workflow WorkOrderWorkflow.TimeReportsStep; // Step name
      }

      navigate {
         workflow WorkOrderWorkflow(3); // Step sequence
      }
   }
}

Hide Workflow commands from Navigation Menu

There is a property on the workflow steps that can be defined for each step. If you don't want the step displaying in the navigation menu, but do want it displaying in the top navigation header, you can add the property hideworkflowcommand to a step and set it to true. The default value is false, so it is only needed on the steps that you want to hide.

Client:

step LineChartStep {
   label = "Line Chart";
   hideworkflowcommand = true;
   navigate LineChartDataPage(WoNo);
}

Change Workflow visiblity

There is a 'visible' property that can be evaluated under the workflow keyword that can be used to define if a workflow is visible or not, an example is below.

workflow WorkOrderWorkflow for TstOffWorkOrder {
   visible = [Objstate != "REJECTED"];
   init command {
      label = "Start Workflow";
      execute {
         alert("Starting completion process of work order...");
      }
   }

Workflow Component State

The following properties are supported in using the workflow state in the client file. - SequenceNo - provides the sequence number of the current step - StepName - provides the name of the current step

Example usage in the client file:

call ValidateStep(WorkflowId, component.DynamicWorkflow.SequenceNo) into Result;

if [component.DynamicWorkflow.StepName = "Step1"] {
   alert("You are in step one");
}