Integration events of Ventoo Shipping

Ventoo Shipping publishes integration events that extensions can use to plug into the label lifecycle. All events are raised by the Shipping Events VTO codeunit (ID 70679804) and declared as [IntegrationEvent(false, false)] in AL.

Lifecycle of a label

When Shipment Label Mgt. VTO.ProcessLabel is called, a label goes through these steps:

  1. OnBeforeProcessLabel is raised.

  2. The carrier setup is loaded and checked for Enabled.

  3. The connector validates the label (ValidateRequest).

  4. OnBeforeBuildRequestPayload is raised.

  5. The connector builds the request payload.

  6. The status is set to Sent and the record is committed.

  7. The carrier API is called.

  8. OnAfterParseResponse is raised.

  9. The connector parses the response and populates the PDF, tracking link, and transport unit number.

  10. On success and when Auto-Print After Creation is enabled, the label is printed.

  11. OnAfterProcessLabel is raised.

Published events

OnBeforeProcessLabel

[IntegrationEvent(false, false)]
procedure OnBeforeProcessLabel(
    var ShipmentLabelHeader: Record "Shipment Label Header VTO";
    var IsHandled: Boolean)

Raised before the actual processing begins. If a subscriber sets IsHandled := true, it takes over the complete processing; the default logic is skipped. Useful to plug in custom connectors or mock implementations.

OnBeforeBuildRequestPayload

[IntegrationEvent(false, false)]
procedure OnBeforeBuildRequestPayload(
    var ShipmentLabelHeader: Record "Shipment Label Header VTO";
    CarrierCode: Code[20])

Raised immediately before BuildRequestPayload is called. Allows you to adjust fields on the label header right before the request is sent (for example to set custom fields that are then read by the connector).

OnAfterParseResponse

[IntegrationEvent(false, false)]
procedure OnAfterParseResponse(
    var ShipmentLabelHeader: Record "Shipment Label Header VTO";
    ResponseBody: Text)

Raised once the HTTP response has been received but before the connector's ParseResponse is called. Useful, for example, to extract additional fields from the response or to write logs.

OnAfterProcessLabel

[IntegrationEvent(false, false)]
procedure OnAfterProcessLabel(
    var ShipmentLabelHeader: Record "Shipment Label Header VTO")

Raised at the end of the processing – after the status update, the PDF being stored, and the optional auto-print. Useful for triggering follow-up actions (notifications, status synchronization with third-party systems).

OnPopulateDeliveryAddress

[IntegrationEvent(false, false)]
procedure OnPopulateDeliveryAddress(
    SourceDocType: Enum "Source Document Type VTO";
    SourceDocNo: Code[20];
    var ShipmentLabelHeader: Record "Shipment Label Header VTO")

Raised when the delivery address is pre-filled from a sales order or a posted sales shipment. Use case: populate additional fields such as Delivery Phone, Delivery Email, or instructions from custom data structures that are not part of the standard Ship-to fields.

Extensibility points

In addition to the integration events, Ventoo Shipping offers further extension points:

  • Carrier type enum (Carrier Type VTO): The enum is Extensible = true. New carriers can add their own value and implement a codeunit that fulfills the Carrier Connector VTO interface.

  • Carrier Connector VTO interface: Defines the methods GetCarrierName, ValidateRequest, BuildRequestPayload, SendRequest, ParseResponse, InitCarrierMasterData, and GetPrintReportId.

  • Print reports: Carrier-specific reports can be registered in the range 7067980170679819. The Ship Label Print Events VTO event subscriber (OnAfterDocumentReady) replaces their output with the carrier PDF.

  • Source Document Type VTO enum: Also Extensible = true. Custom source document types (for example a service order) can be added by adding a new enum value and the corresponding invocation routine (analogous to CreateLabelsFromSalesOrder).