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 -- 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
falseto skip the step entirely. - HandleStep -- executes the step's business logic. Return
truewhen the step completes successfully and the engine should advance. Returnfalsewhen the step needs user input (e.g., a scan or a quantity entry) -- the engine pauses and waits for the next RPC call. - UndoStep -- called when the user navigates backward. Return
trueif the undo was handled (state was rolled back). Returnfalseif 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:
| Name | Type | Direction | Description |
|---|---|---|---|
State | Codeunit MobileRPCState220FDW | var | Current workflow state containing document context, scanned values, and step position. |
ItemMgt | Codeunit MobileItemMgt220FDW | var | Item management helper -- provides methods like IsLotTracked() for checking item tracking requirements. |
WorkflowStep | Record "Mobile Workflow Step 220FDW" | value | The 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:
| Name | Type | Direction | Description |
|---|---|---|---|
State | Codeunit MobileRPCState220FDW | var | Current workflow state. Read scanned input from it and write results back. |
ItemMgt | Codeunit MobileItemMgt220FDW | var | Item management helper for item tracking lookups. |
WorkflowStep | Record "Mobile Workflow Step 220FDW" | value | The 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:
| Name | Type | Direction | Description |
|---|---|---|---|
State | Codeunit MobileRPCState220FDW | var | Current workflow state. Roll back any values that were set during HandleStep. |
ItemMgt | Codeunit MobileItemMgt220FDW | var | Item management helper. |
WorkflowStep | Record "Mobile Workflow Step 220FDW" | value | The 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 Type | Value | Typical Use |
|---|---|---|
Init | 0 | Internal initialization (not used in step handlers) |
Bin | 10 | Capture or validate a bin code |
Item | 20 | Scan an item barcode |
LicensePlate | 30 | Scan a license plate |
LotNumber | 40 | Capture a lot number |
ExpirationDate | 50 | Capture an expiration date |
Quantity | 60 | Enter a quantity |
SerialNumber | 70 | Capture a serial number |
Location | 80 | Select a location |
Variant | 90 | Select an item variant |
ReasonCode | 100 | Select a reason code |
Completed | 200 | Internal 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
elsebranch in yourcasestatements. Raising an error on unsupported step types catches configuration mismatches early. - Return
falsefromHandleStepwhen 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'sStep Input Type. - Guard
IsStepRequiredcarefully. 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
IBCRPC220FDWandIStepHandler220FDW, as seen in the built-inReceiptService220FDW. This lets the service handle RPC dispatch and step logic in a single unit.
See Also
- WorkflowHandlerRegistry220FDW -- resolves
IStepHandler220FDWimplementations via integration events - IBCRPC220FDW -- the RPC service interface, often implemented alongside
IStepHandler220FDW - MobileRPCState220FDW -- request parsing, state management, and response building
- Enums --
StepType220FDWandStepInputType220FDWreference