The AL codes listed here are for Posted Warehouse Shipments. For Warehouse Shipments, please refer to Configuring Microsoft Dynamics for Warehouse Shipment. For a more complete view of integration, please read the Integration Guide of Microsoft Dynamics 365 Business Central.


Before you can connect Shiptheory with Microsoft Dynamics, you need to first set up your Microsoft Dynamics API.


PLEASE NOTE: These instructions are technical and intended to be followed by a Microsoft Dynamics expert. Therefore, please pass these instructions to your Microsoft Dynamics agency.


  1. Ensure your Business Central is set up for OAuth2 authentication with APIs in the Azure Portal, taking note of the client ID and client secret to be used in the integration to authenticate Shiptheory with the Business Central APIs.
  1. Ensure the environment name and company identifier are noted for the specific company you would like Shiptheory to integrate with. For example, ‘Production’ and ‘LIVE-COMPANYNAME’.
  1. Ensure APIs for the following objects are published. The code that needs to be pasted into each object can be found at the end of this article.
    1. shiptheoryPostedWhseShipmentsQuery – contains a query of Posted Warehouse Shipment Header, Warehouse Shipment Lines and Sales Order
    2. shiptheoryPostedWarehouseShipments – API page exposing Posted Warehouse Shipment with Shipment No. e.g. PWS34815
    3. shiptheoryLocations – API page exposing full address and emails for sender information for Warehouse Shipment
  1. Ensure the ship-to address is correctly populated on related sales orders with accurate shipping agent and agent services and any supporting weights, commodity codes, and countries of origin are populated on Warehouse Shipment and Items.

 

Shiptheory will update the ShiptheoryPTR (Package Tracking Reference) and ShiptheoryStatus fields on the Warehouse Shipment Line to show progress.


API Object Code


There are two files:

  • SUKAPIPostedWhseShipments.Page.al
  • SUKPostedWarehouseShipments.Query.al


SUKAPIPostedWhseShipments.Page.al


page 50063 "SUK API Posted Whse Shipments"
{
    APIGroup = 'shipTheory';
    APIPublisher = 'Vendor';
    APIVersion = 'v1.0';
    Caption = 'postedWhseShipments';
    DelayedInsert = true;
    EntityName = 'shiptheoryPostedWarehouseShipments';
    EntitySetName = 'shiptheoryPostedWarehouseShipments';
    PageType = API;
    SourceTable = "Posted Whse. Shipment Header";

    layout
    {
        area(content)
        {
            repeater(General)
            {
                field(assignedUserID; Rec."Assigned User ID")
                {
                    Caption = 'Assigned User ID';
                }
                field(assignmentDate; Rec."Assignment Date")
                {
                    Caption = 'Assignment Date';
                }
                field(assignmentTime; Rec."Assignment Time")
                {
                    Caption = 'Assignment Time';
                }
                field(comment; Rec.Comment)
                {
                    Caption = 'Comment';
                }
                field(externalDocumentNo; Rec."External Document No.")
                {
                    Caption = 'External Document No.';
                }
                field(locationCode; Rec."Location Code")
                {
                    Caption = 'Location Code';
                }
                field(no; Rec."No.")
                {
                    Caption = 'No.';
                }
                field(noSeries; Rec."No. Series")
                {
                    Caption = 'No. Series';
                }
                field(postingDate; Rec."Posting Date")
                {
                    Caption = 'Posting Date';
                }
                field(shipmentDate; Rec."Shipment Date")
                {
                    Caption = 'Shipment Date';
                }
                field(shipmentMethodCode; Rec."Shipment Method Code")
                {
                    Caption = 'Shipment Method Code';
                }
                field(shippingAgentCode; Rec."Shipping Agent Code")
                {
                    Caption = 'Shipping Agent Code';
                }
                field(shippingAgentServiceCode; Rec."Shipping Agent Service Code")
                {
                    Caption = 'Shipping Agent Service Code';
                }
                field(systemCreatedAt; Rec.SystemCreatedAt)
                {
                    Caption = 'SystemCreatedAt';
                }
                field(systemCreatedBy; Rec.SystemCreatedBy)
                {
                    Caption = 'SystemCreatedBy';
                }
                field(systemId; Rec.SystemId)
                {
                    Caption = 'SystemId';
                }
                field(systemModifiedAt; Rec.SystemModifiedAt)
                {
                    Caption = 'SystemModifiedAt';
                }
                field(systemModifiedBy; Rec.SystemModifiedBy)
                {
                    Caption = 'SystemModifiedBy';
                }
                field(whseShipmentNo; Rec."Whse. Shipment No.")
                {
                    Caption = 'Whse. Shipment No.';
                }
                field(shiptheoryPTR; Rec."SUK Shiptheory PTR")

                {
                }

                field(shiptheoryStatus; Rec."SUK Shiptheory Status")
                {
                }
                field(shipToName; Rec."SUK Ship-to Name")
                {

                }
                field(shipToName2; Rec."SUK Ship-to Name 2")
                {

                }
                field(shipToAddress; Rec."SUK Ship-to Address")
                {

                }
                field(shipToAddress2; Rec."SUK Ship-to Address 2")
                {

                }
                field(shipToCity; Rec."SUK Ship-to City")
                {

                }
                field(shipToPostCode; Rec."SUK Ship-to Post Code")
                {

                }
                field(shipToContact; Rec."SUK Ship-to Contact")
                {

                }
                field(shipToCountry; Rec."SUK Ship-to Country/Reg. Code")
                {

                }
                field(sellToEmail; Rec."SUK Sell-to E-mail")
                {

                }
                field(sellToPhoneNo; Rec."SUK Sell-to Phone No.")
                {

                }
                field(sellToVATRegistrationNo; Rec."SUK VAT Registration No.")
                {

                }
            }
        }
    }
}


SUKPostedWarehouseShipments.Query.al


query 50050 "SUK Posted Warehouse Shipments"
{

    QueryType = Normal;

    elements
    {
        dataitem(QueryElement1; "Posted Whse. Shipment Header")

        {

            column(systemIdWhseShipmentHeader; SystemId)

            {

            }

            column(whseShipmentNo; "No.")

            {

            }

            column(shipmentDate; "Shipment Date")

            {

            }

            column(shippingAgentCode; "Shipping Agent Code")

            {

            }

            column(shippingAgentServiceCode; "Shipping Agent Service Code")

            {

            }

            column(shipToName; "SUK Ship-to Name")

            {

            }

            column(shipToAddress; "SUK Ship-to Address")

            {

            }

            column(shipToAddress2; "SUK Ship-to Address 2")

            {

            }

            column(shipToCity; "SUK Ship-to City")

            {

            }

            column(shipToCounty; "SUK Ship-to County")

            {

            }

            column(shipToPostCode; "SUK Ship-to Post Code")

            {

            }

            column(shipToCountryCode; "SUK Ship-to Country/Reg. Code")

            {

            }

            column(sellToEmail; "SUK Sell-to E-Mail")

            {

            }

            column(sellToPhoneNo; "SUK Sell-to Phone No.")

            {

            }

            column(sellToVATRegistrationNo; "SUK VAT Registration No.")

            {

            }

            // Added Location Code for Ship-from Address

            column(locationCode; "Location Code")

            {

            }
            column(shiptheoryPTR; "SUK Shiptheory PTR")

            {

            }

            column(shiptheoryStatus; "SUK Shiptheory Status")

            {

            }

            dataitem(QueryElement10; "Posted Whse. Shipment Line")

            {

                DataItemLink = "No." = QueryElement1."No.";

                SqlJoinType = LeftOuterJoin;

                DataItemTableFilter = "Source Document" = FILTER("Sales Order");

                column(systemIdWhseShipmentLine; SystemId)

                {

                }

                column(sourceNo; "Source No.")

                {

                }

                column(lineNo; "Line No.")

                {

                }

                column(itemNo; "Item No.")

                {

                }

                column(description; Description)

                {

                }

                column(quantity; Quantity)

                {

                }
                column(qtyToShip; Quantity)

                {

                }
                column(unitOfMeasureCode; "Unit of Measure Code")

                {

                }



                column(systemIdSalesOrder; SystemId)

                {

                }


                dataitem(QueryElement1000; "Item")

                {

                    DataItemLink = "No." = QueryElement10."Item No.";

                    SqlJoinType = LeftOuterJoin;



                    column(countryOfOriginCode; "Country/Region of Origin Code")

                    {

                    }

                    dataitem(QueryElement10000; "Item Unit of Measure")

                    {

                        DataItemLink = "Item No." = QueryElement10."Item No.", Code = QueryElement10."Unit of Measure Code";

                        SqlJoinType = LeftOuterJoin;

                        column(weightPerUOM; Weight)

                        {

                        }

                        column(heightPerUOM; Height)

                        {

                        }

                        column(widthPerUOM; Width)

                        {

                        }

                        column(lengthPerUOM; Length)

                        {

                        }

                        column(cubagePerUOM; Cubage)

                        {

                        }
                        dataitem(QueryElement100000; "Tariff Number")

                        {

                            DataItemLink = "No." = QueryElement1000."Tariff No.";

                            SqlJoinType = LeftOuterJoin;



                            column(commodityCode; "No.")

                            {

                            }

                            column(commodityCodeDescription; Description)

                            {

                            }

                        }

                    }

                }


            }

        }

    }
}