Skip to main content

IStepHandler220FDW

The workflow step handler interface that all Aptean Mesh workflow codeunits must implement. Each step in a mobile workflow is routed through this interface so that your service codeunit can decide whether the step applies, execute its logic, and optionally undo it.

Overview

  • Object type: Interface
  • Namespace: Aptean.Mesh.SDUI
  • Purpose: Defines the three-method contract that the workflow engine calls for every step in a mobile workflow

Aptean Mesh workflows are composed of ordered steps stored in the Mobile Workflow Step 220FDW table. As the engine iterates through steps, it calls the resolved IStepHandler220FDW implementation for each one. The handler receives the current MobileRPCState220FDW, a MobileItemMgt220FDW helper, and the Mobile Workflow Step 220FDW record that describes the step being executed.

Step Lifecycle

The workflow engine processes each step through a three-phase lifecycle:

IsStepRequired()
| false----------------> skip to next step
| true
|v
HandleStep()
| false----------------> awaiting user input (pause)
| true
|v
Advance to next step
· · ·
|v
UndoStep()
<── user presses Back
  1. IsStepRequired -- the engine asks whether this step is relevant given the current state. For example, a Lot Number step is only required when the item is lot-tracked. Return false to skip the step entirely.
  2. HandleStep -- executes the step's business logic. Return true when the step completes successfully and the engine should advance. Return false when the step needs user input (e.g., a scan or a quantity entry) -- the engine pauses and waits for the next RPC call.
  3. UndoStep -- called when the user navigates backward. Return true if the undo was handled (state was rolled back). Return false if the step cannot be undone (e.g., a Bin step with no prior state to restore).

Methods

IsStepRequired

procedure IsStepRequired(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"
): Boolean

Determines whether the given step should execute for the current workflow state.

Parameters:

NameTypeDirectionDescription
StateCodeunit MobileRPCState220FDWvarCurrent workflow state containing document context, scanned values, and step position.
ItemMgtCodeunit MobileItemMgt220FDWvarItem management helper -- provides methods like IsLotTracked() for checking item tracking requirements.
WorkflowStepRecord "Mobile Workflow Step 220FDW"valueThe workflow step record being evaluated, including its Step Type and Sequence.

Returns: Boolean -- true if the step should be executed, false to skip it.


HandleStep

procedure HandleStep(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"
): Boolean

Executes the step logic -- validation, data capture, or state mutation.

Parameters:

NameTypeDirectionDescription
StateCodeunit MobileRPCState220FDWvarCurrent workflow state. Read scanned input from it and write results back.
ItemMgtCodeunit MobileItemMgt220FDWvarItem management helper for item tracking lookups.
WorkflowStepRecord "Mobile Workflow Step 220FDW"valueThe workflow step record being handled.

Returns: Boolean -- true if the step completed and the engine should advance to the next step. false if the step requires user input (the engine will pause and return the current state to the client).


UndoStep

procedure UndoStep(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"
): Boolean

Reverses the effect of a previously completed step when the user navigates backward.

Parameters:

NameTypeDirectionDescription
StateCodeunit MobileRPCState220FDWvarCurrent workflow state. Roll back any values that were set during HandleStep.
ItemMgtCodeunit MobileItemMgt220FDWvarItem management helper.
WorkflowStepRecord "Mobile Workflow Step 220FDW"valueThe workflow step record being undone.

Returns: Boolean -- true if the undo was handled, false if the step has no undo logic (e.g., a Bin step that does not store reversible state).

Handling Step Types

The WorkflowStep."Step Type" field is an extensible enum (StepType220FDW) that identifies what kind of data the step captures. Your handler should use a case statement to dispatch to step-specific logic:

Step TypeValueTypical Use
Init0Internal initialization (not used in step handlers)
Bin10Capture or validate a bin code
Item20Scan an item barcode
LicensePlate30Scan a license plate
LotNumber40Capture a lot number
ExpirationDate50Capture an expiration date
Quantity60Enter a quantity
SerialNumber70Capture a serial number
Location80Select a location
Variant90Select an item variant
ReasonCode100Select a reason code
Completed200Internal completion marker (not used in step handlers)

The enum is marked Extensible = true, so you can add custom step types for domain-specific data capture.

Implementation Example

The following example shows a simplified step handler for a warehouse receipt workflow. It demonstrates the typical pattern of dispatching on Step Type and delegating to per-step helper procedures.

codeunit 50100 "My Receipt Handler" implements IStepHandler220FDW
{
// Register with the workflow handler registry
[EventSubscriber(ObjectType::Codeunit,
Codeunit::WorkflowHandlerRegistry220FDW,
OnResolveWorkflowHandler, '', false, false)]
local procedure ResolveHandler(
CodeunitId: Integer;
var StepHandler: Interface IStepHandler220FDW;
var IsResolved: Boolean)
begin
if IsResolved then
exit;
if CodeunitId <> Codeunit::"My Receipt Handler" then
exit;
StepHandler := this;
IsResolved := true;
end;

// ── IsStepRequired ──────────────────────────────────────
procedure IsStepRequired(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
case WorkflowStep."Step Type" of
Enum::StepType220FDW::LotNumber:
exit(ItemMgt.IsLotTracked());
Enum::StepType220FDW::ExpirationDate:
exit(ItemMgt.IsLotTracked());
Enum::StepType220FDW::Quantity:
exit(true); // quantity is always required
Enum::StepType220FDW::Bin:
exit(IsBinMandatoryForLocation(State));
else
Error('Unsupported step type: %1', WorkflowStep."Step Type");
end;
end;

// ── HandleStep ──────────────────────────────────────────
procedure HandleStep(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
case WorkflowStep."Step Type" of
Enum::StepType220FDW::LotNumber:
exit(HandleLot(State, ItemMgt, WorkflowStep));
Enum::StepType220FDW::ExpirationDate:
exit(HandleExpDate(State, WorkflowStep));
Enum::StepType220FDW::Quantity:
exit(HandleQuantity(State, ItemMgt, WorkflowStep));
Enum::StepType220FDW::Bin:
exit(HandleBin(State, WorkflowStep));
else
Error('Unsupported step type: %1', WorkflowStep."Step Type");
end;
end;

// ── UndoStep ────────────────────────────────────────────
procedure UndoStep(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
case WorkflowStep."Step Type" of
Enum::StepType220FDW::LotNumber:
exit(UndoLot(State, ItemMgt, WorkflowStep));
Enum::StepType220FDW::ExpirationDate:
exit(UndoExpDate(State, WorkflowStep));
Enum::StepType220FDW::Quantity:
exit(UndoQuantity(State, ItemMgt, WorkflowStep));
Enum::StepType220FDW::Bin:
exit(false); // bin has no undo logic
else
Error('Unsupported step type: %1', WorkflowStep."Step Type");
end;
end;

// ── Step Handlers (stubs) ───────────────────────────────
local procedure HandleLot(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
// Read the scanned lot from state, validate, store
// Return true when lot is captured, false to prompt user
exit(true);
end;

local procedure HandleExpDate(
var State: Codeunit MobileRPCState220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
exit(true);
end;

local procedure HandleQuantity(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
exit(true);
end;

local procedure HandleBin(
var State: Codeunit MobileRPCState220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
exit(true);
end;

local procedure UndoLot(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
// Clear lot number from state
exit(true);
end;

local procedure UndoExpDate(
var State: Codeunit MobileRPCState220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
exit(true);
end;

local procedure UndoQuantity(
var State: Codeunit MobileRPCState220FDW;
var ItemMgt: Codeunit MobileItemMgt220FDW;
WorkflowStep: Record "Mobile Workflow Step 220FDW"): Boolean
begin
exit(true);
end;

local procedure IsBinMandatoryForLocation(
var State: Codeunit MobileRPCState220FDW): Boolean
begin
// Check location setup to determine if bins are required
exit(false);
end;
}

Key Design Notes

  • Always handle the else branch in your case statements. Raising an error on unsupported step types catches configuration mismatches early.
  • Return false from HandleStep when the step needs user input. The workflow engine will serialize the current state back to the mobile client, which renders the appropriate input control based on the step's Step Input Type.
  • Guard IsStepRequired carefully. Skipping a step incorrectly can cause downstream steps to fail due to missing state. Conversely, requiring a step that has no user-visible input can stall the workflow.
  • The same codeunit typically implements both IBCRPC220FDW and IStepHandler220FDW, as seen in the built-in ReceiptService220FDW. This lets the service handle RPC dispatch and step logic in a single unit.

See Also

  • WorkflowHandlerRegistry220FDW -- resolves IStepHandler220FDW implementations via integration events
  • IBCRPC220FDW -- the RPC service interface, often implemented alongside IStepHandler220FDW
  • MobileRPCState220FDW -- request parsing, state management, and response building
  • Enums -- StepType220FDW and StepInputType220FDW reference