Skip to content

Dynamic Ship · Developer

Leveraging Freight Quotes Externally

Last updated June 3, 2025

Starting in Dynamic Ship 2.8, the app has procedures allowing easier access to the freight quoting mechanic. These signatures are stored in Codeunit “DSHIP Freight Quote Management”. There are several overloads for the procedure, GetFreightQuotesExternal(), that allow passing in a variety of parameters (from sales headers to simply addresses) depending on the quoting complexity required.

These procedures leverage Dynamic Ship’s customer options, freight prices, and other configuration to return quoting identical to leveraging the feature within Business Central.

Example

Here is an example making use of an available procedure to get quotes and then display them. Below is how the code appears:

// In this example the sales information and packages are being passed in from some external source.
internal procedure GetFreightQuotes()
var
    salesHeader: Record "Sales Header" temporary;
    salesLine: Record "Sales Line" temporary;
    rateBuffer: Record "DSHIP Carrier Rate Buffer" temporary;
    lpHeaderBuffer: Record "IWX LP Header" temporary;
    shipMessageBuffer: Record "DSHIP Shipment Message Buffer" temporary;
    freightQuoteMgmt: Codeunit "DSHIP Freight Quote Management";
    rateWorksheet: Page "DSHIP Rate Worksheet";
    errorDetails: Text;
begin
    salesHeader.Init();
    salesHeader."Document Type" := salesHeader."Document Type"::Order;
    salesHeader."No." := 'Example';
    salesHeader."Ship-to Name" := 'Insight Works';
    salesHeader."Ship-to Contact" := 'Knowledge Base';
    salesHeader."Ship-to Address" := '5661 99 St NW';
    salesHeader."Ship-to Address 2" := '102';
    salesHeader."Ship-to City" := 'Edmonton';
    salesHeader."Ship-to County" := 'AB';
    salesHeader."Ship-to Post Code" := 'T6E 3N8';
    salesHeader."Ship-to Country/Region Code" := 'CA';

    // This will determine origin address.
    // This must be a real location.
    salesHeader."Location Code" := 'MAIN';

    // If we want to fully leverage customer options, including Freight Price rules, then we need to supply a customer number.
    // This must be a real customer.
    salesHeader."Sell-to Customer No." := '10000';
    // Optional. If using "Minimum Order Amount" filter in Freight Price rules.
    salesHeader.Amount := 2500;
    // Optional. If using Freight Price rules of Sales Type "Campaign".
    salesHeader."Campaign No." := 'CAMPAIGN1';

    // Optionally the service can be set if we want to limit our results.
    // This must be a real service.
    salesHeader."Shipping Agent Code" := 'UPS';
    salesHeader."Shipping Agent Service Code" := 'STANDARD';

    salesHeader.Insert(false);

    // Sales lines are optional when packages are passed.
    // If passed, they will trigger OnGetFreightQuotesExternalSalesLine() in "DSHIP Event Publisher".
    // This allows further interaction with the packages.
    salesLine.Init();
    salesLine."Line No." := 10000;
    salesLine.Type := salesLine.Type::Item;
    salesLine."No." := '1000';
    salesLine.Insert(false);

    // The License Plate Header is required, as it represents the package(s).
    lpHeaderBuffer.Init();
    lpHeaderBuffer."No." := 'LPTEST01';
    lpHeaderBuffer."Shipment Length" := 10;
    lpHeaderBuffer."Shipment Width" := 10;
    lpHeaderBuffer."Shipment Height" := 10;
    lpHeaderBuffer."Shipment Gross Weight" := 10;
    // This must be a real unit of measure from the "IWX Unit of Measure" table.
    lpHeaderBuffer."Weight Unit of Measure" := 'LB';
    // This must be a real unit of measure from the "IWX Unit of Measure" table.
    lpHeaderBuffer."Shpt. Dim. Unit of Measure" := 'INCH';
    lpHeaderBuffer.Insert();

    // Note that while this returns errors, an uncontrolled runtime could still occur.
    errorDetails := freightQuoteMgmt.GetFreightQuotesExternal(salesHeader, salesLine, lpHeaderBuffer, rateBuffer, shipMessageBuffer);

    if (errorDetails <> '') then begin
        Error(errorDetails);
    end;

    rateWorksheet.RunModal();
end;

Signatures

The full outline for all signatures is available on the Codeunit DSHIP Freight Quote Management page.

View this article as Markdown

Still need help?

Ask other Business Central users in the Insight Works community, or send the details to the support team. Include the steps you took and any error message you saw.