Skip to main content

MobileCommandBuilder220FDW

Builder for queuing commands that control mobile app behavior -- alerts, confirmations, navigation, haptic feedback, and screen refresh.

Overview

  • Object type: Codeunit
  • Object ID: 73167874
  • Access: Public
  • Namespace: Aptean.Mesh.SDUI

The command builder uses a fluent API where every method returns this, so you can chain multiple commands in a single expression. Commands are buffered internally and flushed into the JSON-RPC response when you call State.Serialize().

// Fluent chaining -- queue multiple commands in one statement
State.Command()
.Alert('Error', 'Item not found')
.VibrateError();

exit(State.Serialize());
tip

You do not need to instantiate MobileCommandBuilder220FDW directly. Access it through State.Command() on the MobileRPCState220FDW object.


Dialogs

Alert

procedure Alert(Title: Text; Message: Text): Codeunit MobileCommandBuilder220FDW

Shows a popup alert dialog on the mobile device. The user taps OK to dismiss.

Parameters:

NameTypeDescription
TitleTextDialog title
MessageTextDialog message body

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

State.Command().Alert('Success', 'The receipt has been posted.');

JSON output:

{ "type": "alert", "title": "Success", "message": "The receipt has been posted." }

Confirm

procedure Confirm(Title: Text; Message: Text; ConfirmLabel: Text; Action: Text): Codeunit MobileCommandBuilder220FDW

Shows a confirmation dialog with a custom button label. When the user taps the confirm button, the specified Action is sent back to Business Central as a new RPC call.

Parameters:

NameTypeDescription
TitleTextDialog title
MessageTextDialog message body
ConfirmLabelTextLabel for the confirm button
ActionTextAction ID sent back to BC when the user confirms

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

State.Command().Confirm(
'Delete Line',
'Are you sure you want to remove this line?',
'Delete',
'confirmDeleteLine'
);

procedure Navigate(Destination: Code[50]): Codeunit MobileCommandBuilder220FDW

Navigates forward to a new screen by its page code.

Parameters:

NameTypeDescription
DestinationCode[50]The target page code (e.g., 'DETAIL', 'RECEIPT')

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


procedure Navigate(Destination: Code[50]; NavigationData: JsonObject): Codeunit MobileCommandBuilder220FDW

Navigates forward to a new screen with a data payload. The navigation data is available in the target screen's input.

Parameters:

NameTypeDescription
DestinationCode[50]The target page code
NavigationDataJsonObjectData to pass to the target screen

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

var
NavData: JsonObject;
begin
NavData.Add('documentNo', 'WH-REC-001');
NavData.Add('lineNo', 10000);
State.Command().Navigate('RECEIPT', NavData);
end;

procedure Navigate(Destination: Code[50]; AlertTitle: Text; AlertMessage: Text): Codeunit MobileCommandBuilder220FDW

Shows an alert dialog, then pushes a new screen when the user dismisses it.

Parameters:

NameTypeDescription
DestinationCode[50]The target page code
AlertTitleTextAlert dialog title
AlertMessageTextAlert dialog message

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


procedure Navigate(Destination: Code[50]; NavigationData: JsonObject; AlertTitle: Text; AlertMessage: Text): Codeunit MobileCommandBuilder220FDW

Shows an alert, then pushes a new screen with a data payload when the user dismisses it.

Parameters:

NameTypeDescription
DestinationCode[50]The target page code
NavigationDataJsonObjectData to pass to the target screen
AlertTitleTextAlert dialog title
AlertMessageTextAlert dialog message

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


procedure NavBack(): Codeunit MobileCommandBuilder220FDW

Navigates back to the previous screen in the navigation stack.

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

// After deleting a line, go back to the list
State.Command().NavBack().VibrateSuccess();
exit(State.Serialize());

procedure NavBack(AlertTitle: Text; AlertMessage: Text): Codeunit MobileCommandBuilder220FDW

Shows an alert dialog, then pops the current screen when the user dismisses it.

Parameters:

NameTypeDescription
AlertTitleTextAlert dialog title
AlertMessageTextAlert dialog message

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

State.Command().NavBack('Posted', 'Receipt was successfully posted.');

procedure NavBackTo(Destination: Code[50]): Codeunit MobileCommandBuilder220FDW

Navigates back to a specific screen by name in the navigation stack. All screens above the destination are removed.

Parameters:

NameTypeDescription
DestinationCode[50]The page code to navigate back to

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


procedure NavBackTo(Destination: Code[50]; AlertTitle: Text; AlertMessage: Text): Codeunit MobileCommandBuilder220FDW

Shows an alert, then pops back to the named destination when the user dismisses it.

Parameters:

NameTypeDescription
DestinationCode[50]The page code to navigate back to
AlertTitleTextAlert dialog title
AlertMessageTextAlert dialog message

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.

Example:

// After completing a workflow, go back to Home with a success message
State.Command().NavBackTo('HOME', 'Complete', 'Put-away finished successfully.');

Feedback

VibrateError

procedure VibrateError(): Codeunit MobileCommandBuilder220FDW

Triggers device vibration with an error haptic pattern. Use when something goes wrong (invalid barcode, failed validation, etc.).

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


VibrateSuccess

procedure VibrateSuccess(): Codeunit MobileCommandBuilder220FDW

Triggers device vibration with a success haptic pattern. Use when an action completes successfully.

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


RefreshScreen

procedure RefreshScreen(): Codeunit MobileCommandBuilder220FDW

Reloads the current screen by re-invoking its initial action. Use after data changes that affect the list or detail view.

Returns: Codeunit MobileCommandBuilder220FDW -- self, for chaining.


Terminal Methods

Build

procedure Build(): JsonArray

Returns all buffered commands as a JsonArray and clears the internal buffer. You typically do not call this directly -- State.Serialize() calls it automatically.

Returns: JsonArray -- the buffered commands.


HasContent

procedure HasContent(): Boolean

Returns true if any commands have been buffered.

Returns: Boolean


Complete Example

local procedure HandleScanItem(var State: Codeunit MobileRPCState220FDW): JsonObject
var
Item: Record Item;
ScannedBarcode: Text;
begin
ScannedBarcode := State.GetScannedValue('01');

Item.SetRange("No.", ScannedBarcode);
if not Item.FindFirst() then begin
State.Command()
.Alert('Not Found', 'No item matches the scanned barcode.')
.VibrateError();
exit(State.Serialize());
end;

State
.SetItemNo(Item."No.", true)
.SetDocumentNo('WH-001');

State.Command().VibrateSuccess();
exit(State.Serialize());
end;

See Also