MobileRPCState220FDW
State management for mobile RPC requests and responses. This is the primary codeunit you interact with inside an IBCRPC220FDW handler. It parses the incoming request, provides typed accessors for all standard fields, and builds the JSON-RPC response.
Overview
- Object type: Codeunit
- Object ID: 73167882
- Access: Public
- Namespace:
Aptean.Mesh.SDUI
The state object supports fluent chaining on setter methods, so you can write concise pipelines:
State
.SetDocumentNo('WH-001')
.SetLineNo(10000)
.SetItemNo('ITEM-A', true)
.SetBinCode('BIN-01', true);
Request / Response Lifecycle
1. Registry calls State.Hydrate(RequestJson)
|
2. Your RPC handler reads from State:
|- State.Method() -- which method to execute
|- State.GetDocumentNo() -- typed workflow getters
|- State.GetInput(...) -- raw input values
|- State.GetScannedValue() -- barcode + input combined
|
3. Your handler writes to State:
|- State.SetDocumentNo() -- update workflow
|- State.SetResult(...) -- add result data
|- State.Command() -- add navigation/alert commands
|- State.UI() -- build info pane
|
4. Return State.Serialize() as the response
Hydration
Hydrate
procedure Hydrate(Request: JsonObject)
Parses the incoming JSON-RPC request and populates all internal state. The MobileRPCRegistry220FDW calls this automatically before invoking your RPC() method, so you typically do not need to call it yourself.
Extracts from the request:
- Root fields:
method,id - Params:
bundle,service,clientVersion,workflow,input,barcode,locationFilter - Nested:
input.workflow(workflow state),input.view(view state), barcode fields
Parameters:
| Name | Type | Description |
|---|---|---|
Request | JsonObject | The raw JSON-RPC request object |
Request Accessors
Methods for reading top-level request metadata.
Bundle
procedure Bundle(): Guid
Returns the app bundle GUID. Throws an error if the bundle is missing from the request.
Returns: Guid -- the app bundle identifier.
BundleOrEmpty
procedure BundleOrEmpty(): Guid
Returns the app bundle GUID without validation. Returns an empty GUID if not present. Useful for logging scenarios.
Returns: Guid
Service
procedure Service(): Code[50]
Returns the mobile service code (e.g., 'PUTAWAY'). Throws an error if the service is missing.
Returns: Code[50]
ServiceOrEmpty
procedure ServiceOrEmpty(): Code[50]
Returns the service code without validation. Returns empty if not present.
Returns: Code[50]
Method
procedure Method(): Text[50]
Returns the RPC method name from the request (e.g., 'Initialize', 'ScanItem'). This corresponds to the endpoint configured in the page JSON action.
Returns: Text[50]
RequestId
procedure RequestId(): Integer
Returns the JSON-RPC request ID. Used for correlating responses with requests.
Returns: Integer
ClientVersion
procedure ClientVersion(): Integer
Returns the mobile client VERSION_CODE (integer). Use this for feature gating based on the app version.
Returns: Integer
GetCurrentLocation
procedure GetCurrentLocation(): Code[10]
Returns the location filter sent by the mobile client. If the client sent 'ALL', this resolves to an empty string.
Returns: Code[10]
GetDefaultLocation
procedure GetDefaultLocation(): Code[10]
Returns the default warehouse location for the current user, read from the Warehouse Employee table during hydration.
Returns: Code[10]
Document Context -- Typed Getters
These methods read standard warehouse fields from the workflow state with type-safe return values. Each accepts a ShowError parameter -- when true, an error is raised if the field is missing.
GetDocumentNo
procedure GetDocumentNo(ShowError: Boolean): Code[20]
Returns the document number from workflow state.
Parameters:
| Name | Type | Description |
|---|---|---|
ShowError | Boolean | If true, throws an error when the value is missing |
Returns: Code[20]
GetLineNo
procedure GetLineNo(ShowError: Boolean): Integer
Returns the line number from workflow state.
Returns: Integer
GetItemNo
procedure GetItemNo(ShowError: Boolean): Code[20]
Returns the item number from workflow state.
Returns: Code[20]
GetVariantCode
procedure GetVariantCode(ShowError: Boolean): Code[10]
Returns the variant code from workflow state.
Returns: Code[10]
GetLotNo
procedure GetLotNo(ShowError: Boolean): Code[50]
Returns the lot number from workflow state.
Returns: Code[50]
GetBinCode
procedure GetBinCode(ShowError: Boolean): Code[20]
Returns the bin code from workflow state.
Returns: Code[20]
GetLocationCode
procedure GetLocationCode(ShowError: Boolean): Code[10]
Returns the location code from workflow state.
Returns: Code[10]
GetHasTracking
procedure GetHasTracking(): Boolean
Returns whether item tracking is active for the current line. Does not throw on missing values -- returns false by default.
Returns: Boolean
GetSelectedUOM
procedure GetSelectedUOM(ShowError: Boolean): Code[10]
Returns the selected unit of measure from workflow state.
Returns: Code[10]
GetLastEnteredQty
procedure GetLastEnteredQty(): Decimal
Returns the last entered quantity from workflow state. Returns 0 if not set.
Returns: Decimal
Document Context -- Typed Setters
Setter methods update workflow state and return this for fluent chaining. Methods with an UpdateInfoPane parameter will also update the corresponding field in the view's info pane display when set to true.
SetDocumentNo
procedure SetDocumentNo(DocumentNo: Code[20]): Codeunit MobileRPCState220FDW
Sets the document number in workflow state.
Returns: Codeunit MobileRPCState220FDW -- self, for chaining.
SetLineNo
procedure SetLineNo(LineNo: Integer): Codeunit MobileRPCState220FDW
Sets the line number in workflow state.
SetItemNo
procedure SetItemNo(ItemNo: Code[20]; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the item number. When UpdateInfoPane is true, also updates the "Item" field in the info pane.
SetVariantCode
procedure SetVariantCode(NewVariantCode: Code[10]): Codeunit MobileRPCState220FDW
Sets the variant code in workflow state.
SetLotNo
procedure SetLotNo(LotNo: Code[50]; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the lot number. When UpdateInfoPane is true, also updates the "Lot No." field in the info pane.
SetBinCode
procedure SetBinCode(BinCode: Code[20]; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the bin code. When UpdateInfoPane is true, also updates the "Bin" field in the info pane.
SetLocationCode
procedure SetLocationCode(LocationCode: Code[10]): Codeunit MobileRPCState220FDW
Sets the location code in workflow state.
SetHasTracking
procedure SetHasTracking(HasTracking: Boolean): Codeunit MobileRPCState220FDW
Sets the item tracking flag in workflow state.
SetSelectedUOM
procedure SetSelectedUOM(UOM: Code[10]; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the selected unit of measure. When UpdateInfoPane is true, also updates the "Unit of Measure" field in the info pane.
SetScannedQty
procedure SetScannedQty(Qty: Decimal; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Updates the scanned quantity display. When UpdateInfoPane is true, updates the "Scanned Qty" field in the info pane. Note: this method only updates the info pane -- it does not store the quantity in workflow state.
SetExpDate
procedure SetExpDate(ExpDate: Date; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the expiration date in workflow state (stored as ISO date string). When UpdateInfoPane is true, also updates the "Expiration Date" field.
SetQuantity
procedure SetQuantity(Qty: Decimal; UpdateInfoPane: Boolean): Codeunit MobileRPCState220FDW
Sets the quantity in workflow state. When UpdateInfoPane is true, also updates the "Quantity" field in the info pane.
JSON Key Accessors
These methods return the standard JSON key names used in the workflow state object. Use them when you need to perform custom JSON operations with JsonHelper220FDW instead of using the typed getters/setters.
| Method | Returns | JSON Key |
|---|---|---|
DocumentNoKey() | Text[30] | documentNo |
LineNoKey() | Text[30] | lineNo |
ItemKey() | Text[30] | item |
VariantKey() | Text[30] | variant |
LotKey() | Text[30] | lot |
BinKey() | Text[30] | bin |
LocationCodeKey() | Text[30] | locationCode |
QuantityKey() | Text[30] | quantity |
SourceTypeKey() | Text[30] | sourceType |
SourceNoKey() | Text[30] | sourceNo |
SourceDocKey() | Text[30] | sourceDocument |
SelectedUOMKey() | Text[30] | selectedUOM |
TrackingQtyKey() | Text[30] | trackingQty |
ValueKey() | Text[30] | value |
LastEnteredQtyKey() | Text[30] | lastEnteredQty |
HasTrackingKey() | Text[30] | hasTracking |
ExpDateKey() | Text[30] | expDate |
FromBinKey() | Text[30] | fromBin |
ToBinKey() | Text[30] | toBin |
Display Label Accessors
These methods return the human-readable labels used for info pane fields. Use them with UpdateViewField() or when building custom info pane entries.
| Method | Returns | Label |
|---|---|---|
ItemLabel() | Text[30] | Item |
LotLabel() | Text[30] | Lot No. |
BinLabel() | Text[30] | Bin |
QuantityLabel() | Text[30] | Quantity |
LineNoLabel() | Text[30] | Line No. |
LocationLabel() | Text[30] | Location |
UOMLabel() | Text[30] | Unit of Measure |
VariantLabel() | Text[30] | Variant Code |
SourceNoLabel() | Text[30] | Source No. |
SourceDocLabel() | Text[30] | Source Document |
DocumentNoLabel() | Text[30] | Document No. |
ScannedQtyLabel() | Text[30] | Scanned Qty |
QtyOutstandingLabel() | Text[30] | Qty Outstanding |
SuggestedBinLabel() | Text[30] | Suggested Bin |
VendorLabel() | Text[30] | Vendor |
DueDateLabel() | Text[30] | Due Date |
DocumentStatusLabel() | Text[30] | Document Status |
ExpDateLabel() | Text[30] | Expiration Date |
PickNoLabel() | Text[30] | Pick No. |
PlaceBinLabel() | Text[30] | Place Bin |
FromBinLabel() | Text[30] | From Bin |
ToBinLabel() | Text[30] | To Bin |
FromLocationLabel() | Text[30] | From Location |
ToLocationLabel() | Text[30] | To Location |
Barcode Accessors
Methods for working with barcode scan data sent by the mobile client.
RawBarcode
procedure RawBarcode(): Text
Returns the raw barcode string exactly as scanned by the device.
Returns: Text
Symbology
procedure Symbology(): Code[20]
Returns the scanner symbology (e.g., 'CODE128', 'QR', 'EAN13').
Returns: Code[20]
BarcodeDataType
procedure BarcodeDataType(): Code[20]
Returns the parsed barcode data type (e.g., 'GS1', 'EAN128', 'SSCC').
Returns: Code[20]
HasBarcodeError
procedure HasBarcodeError(): Boolean
Returns true if barcode parsing failed on the client side.
Returns: Boolean
GetDataFromAICode
procedure GetDataFromAICode(AICode: Code[30]): Text[100]
Returns the value for a specific GS1 Application Identifier from the parsed barcode data.
Parameters:
| Name | Type | Description |
|---|---|---|
AICode | Code[30] | The GS1 Application Identifier code |
Returns: Text[100] -- the parsed value, or empty if not found.
Common AI codes:
| AI Code | Description |
|---|---|
'01' | GTIN |
'10' | Lot/Batch Number |
'17' | Expiration Date (YYMMDD) |
'21' | Serial Number |
'37' | Quantity |
GetScannedValue (simple)
procedure GetScannedValue(AICode: Code[30]): Text[100]
Gets the scanned value by checking the value input field first, then falling back to barcode AI data, then to the raw barcode for non-GS1 barcodes. This is the recommended method for reading scanned input in most scenarios.
Parameters:
| Name | Type | Description |
|---|---|---|
AICode | Code[30] | GS1 AI code(s) to look up. Supports multiple codes separated by ; (e.g., '01;02') |
Returns: Text[100]
GetScannedValue (with custom input key)
procedure GetScannedValue(InputKey: Text; AICode: Code[30]): Text[100]
Same as above but reads from a custom input key instead of the default value key.
Parameters:
| Name | Type | Description |
|---|---|---|
InputKey | Text | The input key to check first |
AICode | Code[30] | GS1 AI code(s) to fall back to. Supports ;-separated list. |
Returns: Text[100]
Resolution order:
- Input field (
InputKey) - Barcode AI data (tries each code in the
;-separated list) - Raw barcode string (only for non-GS1 barcodes or failed GS1 parsing)
HasBarcodeAI
procedure HasBarcodeAI(AICode: Code[10]): Boolean
Returns true if the scanned barcode contains the specified GS1 Application Identifier.
Returns: Boolean
GetParsedBarcodeData
procedure GetParsedBarcodeData(var Data: Record ParsedBarcodeData220FDW)
Copies the full parsed barcode buffer for direct iteration over all AI code/value pairs.
Parameters:
| Name | Type | Description |
|---|---|---|
Data | Record ParsedBarcodeData220FDW | Receives a copy of the parsed barcode data |
ParseGS1Date
procedure ParseGS1Date(GS1DateText: Text): Date
Parses a GS1 expiration date string in YYMMDD format. If the day portion is 00, it returns the last day of the month.
Parameters:
| Name | Type | Description |
|---|---|---|
GS1DateText | Text | The 6-character date string (e.g., '261231' for Dec 31, 2026) |
Returns: Date -- the parsed date, or 0D if the format is invalid.
Example:
var
ExpDate: Date;
begin
// Parse AI(17) expiration date from barcode
if State.HasBarcodeAI('17') then begin
ExpDate := State.ParseGS1Date(State.GetDataFromAICode('17'));
State.SetExpDate(ExpDate, true);
end;
end;
Input Accessors
Methods for reading values from the input object in the request. Input values come from navigation data parameters, form input components, and filter selections on the page.
GetInput
procedure GetInput(KeyName: Text; ShowError: Boolean): Text
Returns a text value from the input object.
Parameters:
| Name | Type | Description |
|---|---|---|
KeyName | Text | The input field key |
ShowError | Boolean | If true, throws an error when missing |
Returns: Text
GetInputInt
procedure GetInputInt(KeyName: Text; ShowError: Boolean): Integer
Returns an integer value from the input object.
GetInputDecimal
procedure GetInputDecimal(KeyName: Text; ShowError: Boolean): Decimal
Returns a decimal value from the input object.
GetInputBool
procedure GetInputBool(KeyName: Text; ShowError: Boolean): Boolean
Returns a boolean value from the input object.
HasInput
procedure HasInput(KeyName: Text): Boolean
Returns true if the input object contains the specified key.
Returns: Boolean
ClearInput
procedure ClearInput(KeyName: Text)
Removes a key from the input object. Use this to prevent stale values from being reused on subsequent calls.
Workflow State Access
Generic read/write access to the workflow state object. These are the building blocks that the typed getters/setters use internally. Use them for custom fields that are not covered by the typed accessors.
All setter methods return Codeunit MobileRPCState220FDW for fluent chaining.
GetWorkflowText / SetWorkflow
procedure GetWorkflowText(KeyName: Text; ShowError: Boolean): Text
procedure SetWorkflow(KeyName: Text; Value: Text): Codeunit MobileRPCState220FDW
GetWorkflowInt / SetWorkflowInt
procedure GetWorkflowInt(KeyName: Text; ShowError: Boolean): Integer
procedure SetWorkflowInt(KeyName: Text; Value: Integer): Codeunit MobileRPCState220FDW
GetWorkflowBool / SetWorkflowBool
procedure GetWorkflowBool(KeyName: Text; ShowError: Boolean): Boolean
procedure SetWorkflowBool(KeyName: Text; Value: Boolean): Codeunit MobileRPCState220FDW
GetWorkflowDecimal / SetWorkflowDecimal
procedure GetWorkflowDecimal(KeyName: Text; ShowError: Boolean): Decimal
procedure SetWorkflowDecimal(KeyName: Text; Value: Decimal): Codeunit MobileRPCState220FDW
GetWorkflowDate / SetWorkflowDate
procedure GetWorkflowDate(KeyName: Text; ShowError: Boolean): Date
procedure SetWorkflowDate(KeyName: Text; Value: Date): Codeunit MobileRPCState220FDW
Dates are stored as ISO format strings (YYYY-MM-DD). 0D is stored as an empty string.
Workflow
procedure Workflow(): Code[20]
Returns the workflow code from the request params. Throws an error if empty.
Returns: Code[20]
GetCurrentStep / SetCurrentStep
procedure GetCurrentStep(): Enum StepType220FDW
procedure SetCurrentStep(Step: Enum StepType220FDW): Codeunit MobileRPCState220FDW
Gets or sets the current workflow step. The step type is an enum that represents the kind of input the mobile app should prompt for next.
GetCurrentSequence / SetCurrentSequence
procedure GetCurrentSequence(): Integer
procedure SetCurrentSequence(Sequence: Integer): Codeunit MobileRPCState220FDW
Gets or sets the current workflow sequence number. The sequence determines the order of steps within a workflow.
GetQuantityStepSequence
procedure GetQuantityStepSequence(): Integer
Returns the sequence number of the Quantity step in the current workflow, or 0 if not found. Reads from the Mobile Workflow Step table.
Returns: Integer
RemoveWorkflow
procedure RemoveWorkflow(KeyName: Text): Codeunit MobileRPCState220FDW
Removes a key from the workflow state. Returns self for chaining.
GetWorkflowObject
procedure GetWorkflowObject(): JsonObject
Returns the raw workflow JSON object for advanced scenarios where the typed accessors are not sufficient.
Returns: JsonObject
HasWorkflow
procedure HasWorkflow(KeyName: Text): Boolean
Returns true if the workflow state contains the specified key.
View State Access
The view state holds display-related data such as info pane fields and UI component values. It is separate from the workflow state.
GetView / SetView
procedure GetView(KeyName: Text; ShowError: Boolean): Text
procedure SetView(KeyName: Text; Value: Text): Codeunit MobileRPCState220FDW
GetViewInt / SetViewInt
procedure GetViewInt(KeyName: Text; ShowError: Boolean): Integer
procedure SetViewInt(KeyName: Text; Value: Integer): Codeunit MobileRPCState220FDW
GetViewBool / SetViewBool
procedure GetViewBool(KeyName: Text; ShowError: Boolean): Boolean
procedure SetViewBool(KeyName: Text; Value: Boolean): Codeunit MobileRPCState220FDW
GetViewDecimal / SetViewDecimal
procedure GetViewDecimal(KeyName: Text; ShowError: Boolean): Decimal
procedure SetViewDecimal(KeyName: Text; Value: Decimal): Codeunit MobileRPCState220FDW
RemoveView
procedure RemoveView(KeyName: Text)
Removes a key from the view state.
GetViewObject
procedure GetViewObject(): JsonObject
Returns the raw view JSON object.
HasView
procedure HasView(KeyName: Text): Boolean
Returns true if the view state contains the specified key.
HasViewField
procedure HasViewField(FieldLabel: Text): Boolean
Returns true if the view state contains a display field with the given label. Delegates to the UI builder internally.
Response Building
Methods for constructing the response payload that is returned to the mobile client.
SetResult
procedure SetResult(KeyName: Text; Value: Text)
Adds a text value to the result object.
SetResultInt
procedure SetResultInt(KeyName: Text; Value: Integer)
Adds an integer value to the result object.
SetResultBool
procedure SetResultBool(KeyName: Text; Value: Boolean)
Adds a boolean value to the result object.
SetResultDecimal
procedure SetResultDecimal(KeyName: Text; Value: Decimal)
Adds a decimal value to the result object.
SetResultObject
procedure SetResultObject(KeyName: Text; Value: JsonObject)
Adds a JSON object to the result object.
SetResultArray
procedure SetResultArray(KeyName: Text; Value: JsonArray)
Adds a JSON array to the result object.
GetResultObject
procedure GetResultObject(): JsonObject
Returns the raw result JSON object for advanced manipulation.
SetInfoPane
procedure SetInfoPane(InfoPaneJObj: JsonObject)
Merges the info pane JSON into the view state. Typically you use State.UI() to build the info pane instead of calling this directly.
UpdateViewField
procedure UpdateViewField(FieldLabel: Text; NewValue: Text): Codeunit MobileRPCState220FDW
Updates a single field in the view's info pane by its display label, without rebuilding the entire pane.
When to use UpdateViewField vs State.UI():
| Scenario | Use |
|---|---|
| Page first loads — build the full pane with all fields | State.UI().InfoPane(...).Field(...).Field(...) |
| A scan updates one field (e.g. Lot No.) but the rest stays the same | State.UpdateViewField(State.LotLabel(), LotNo) |
| Quantity changes and the gauge must update | State.UpdateViewQtyWithGauge(State.QuantityLabel(), Total, Scanned) |
Rebuilding the full pane on every call is correct but slightly more expensive. For hot paths (scan processing), prefer UpdateViewField to avoid re-serialising unchanged fields.
// ✅ Incremental update — only the Bin field changes
State.UpdateViewField(State.BinLabel(), NewBinCode);
// ✅ Rebuild — used in Initialize when building the pane from scratch
State.UI()
.InfoPane(Item.Description, Item."No.")
.WithItemImage(Item."No.")
.Field(State.LotLabel(), LotNo)
.Field(State.BinLabel(), BinCode)
.FieldQtyWithGauge(State.QuantityLabel(), ScannedQty, OutstandingQty);
UpdateViewFieldWithGauge
procedure UpdateViewFieldWithGauge(FieldLabel: Text; NewValue: Text; GaugePercent: Integer): Codeunit MobileRPCState220FDW
Updates a field and its associated gauge (0--100 percent) in the view's info pane.
UpdateViewQtyWithGauge
procedure UpdateViewQtyWithGauge(FieldLabel: Text; TotalQty: Decimal; ScannedQty: Decimal): Codeunit MobileRPCState220FDW
Updates a quantity field with an auto-calculated gauge showing progress (scanned vs. total).
SetScanInput
procedure SetScanInput(ScanInputJObj: JsonObject)
Attaches a scan input configuration to the result. Typically built using State.StepInput() instead of calling this directly.
SetCommands
procedure SetCommands(CommandsArr: JsonArray)
Attaches a commands array to the result. Typically built using State.Command() instead of calling this directly.
Builders
Accessor methods that return embedded builder codeunits. These builders accumulate configuration and are automatically flushed into the response when Serialize() is called.
Command
procedure Command(): Codeunit MobileCommandBuilder220FDW
Returns the command builder for adding navigation, alerts, toasts, and other client-side commands to the response.
UI
procedure UI(): Codeunit MobileUIBuilder220FDW
Returns the UI builder for constructing info pane displays with labeled field rows.
StepInput
procedure StepInput(): Codeunit MobileWorkflowBuilder220FDW
Returns the workflow builder for configuring the next scan/input prompt shown to the user.
Serialization
Serialize
procedure Serialize(): JsonObject
Builds the final JSON-RPC response. This method:
- Flushes any pending builder content (commands, scan input, info pane)
- Assembles the workflow state, view state, and result data into the response
- Adds the request ID for correlation
Call this as the last line in your RPC handler.
Returns: JsonObject -- the complete response.
Example:
procedure RPC(var State: Codeunit MobileRPCState220FDW) ResponseJson: JsonObject
begin
case State.Method() of
'Initialize':
Initialize(State);
'ScanItem':
ScanItem(State);
end;
ResponseJson := State.Serialize();
end;
The response structure:
{
"workflow": { "documentNo": "WH-001", "currentStep": 2 },
"view": { "fields": [...] },
"scanInput": { ... },
"commands": [ ... ],
"customKey": "customValue",
"id": 1
}
See Also
- IBCRPC220FDW -- the interface your service codeunit implements
- MobileRPCRegistry220FDW -- the dispatcher that routes requests
- JsonHelper220FDW -- the utility used internally for all JSON operations