Before you can connect Shiptheory with Microsoft Dynamics, you need to first setup 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 API’s 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 API’s.
  1. Ensure the environment name and company identifier is noted for the specific company you would like Shiptheory to integrate with. For example ‘Production’ and ‘LIVE-COMPANYNAME’.
  1. Ensure API’s 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. shiptheoryWhseShipments – contains a query of Warehouse Shipment Header, Warehouse Shipment Lines and Sales Order
    2. shiptheoryWarehouseShipmentLine – API page exposing Warehouse Shipment Lines with SystemId as PK
    3. shiptheoryLocations – API page exposing full address and emails for sender information for Warehouse Shipment
  1. Warehouse Shipments are passed over to Shiptheory based on their Status. Shiptheory will only consider Warehouse Shipments which are Released. Also, 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, 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:

Paste each of these code snippets into the corresponding API object, do not edit the code snippets.



shiptheoryWhseShipments


      dataitem(QueryElement1; "Warehouse Shipment Header")

        {

            column(systemIdWhseShipmentHeader; SystemId)

            {

            }

            column(whseShipmentNo; "No.")

            {

            }

            column(status; Status)

            {

            }

            column(shipmentDate; "Shipment Date")

            {

            }

            column(shippingAgentCode; "Shipping Agent Code")

            {

            }

            column(shippingAgentServiceCode; "Shipping Agent Service Code")

            {

            }

            // Added Location Code for Ship-from Address

            column(locationCode; "Location Code")

            {

            }

            dataitem(QueryElement10; "Warehouse 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; "Qty. to Ship")

                {

                }

                column(qtyShipped; "Qty. Shipped")

                {

                }

                column(unitOfMeasureCode; "Unit of Measure Code")

                {

                }

                column(shiptheoryPTR; ShiptheoryPTR)

                {

                }

                column(shiptheoryStatus; ShiptheoryStatus)

                {

                }

 

                dataitem(QueryElement100; "Sales Header")

                {

                    DataItemLink = "No." = QueryElement10."Source No.";

                    SqlJoinType = LeftOuterJoin;

                    DataItemTableFilter = "Document Type" = FILTER(Order);

                    column(systemIdSalesOrder; SystemId)

                    {

                    }

                    column(shipToName; "Ship-to Name")

                    {

                    }

                    column(shipToAddress; "Ship-to Address")

                    {

                    }

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

                    {

                    }

                    column(shipToCity; "Ship-to City")

                    {

                    }

                    column(shipToCounty; "Ship-to County")

                    {

                    }

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

                    {

                    }

                    column(shipToCountryCode; "Ship-to Country/Region Code")

                    {

                    }

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

                    {

                    }

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

                    {

                    }

                    column(sellToVATRegistrationNo; "VAT Registration No.")

                    {

                    }

 

                    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)

                                {

                                }

                            }

                        }

                    }

                }

            }

        }


shiptheoryWarehouseShipmentLine


             field(systemId; Rec.SystemId)

                {

                }

                field(no; Rec."No.")

                {

                }

                field(lineNo; Rec."Line No.")

                {

                }

                field(sourceNo; Rec."Source No.")

                {

                }

                field(sourceLineNo; Rec."Source Line No.")

                {

                }

                field(itemNo; Rec."Item No.")

                {

                }

                field(description; Rec.Description)

                {

                }

                field(shiptheoryPTR; Rec.ShiptheoryPTR)

                {

                }

                field(shiptheoryStatus; Rec.ShiptheoryStatus)

                {

                }


shiptheoryLocations


               field(code; Rec.Code)

                {

                }

                field(name; Rec.Name)

                {

                    Caption = 'Name';

                }

                field(address; Rec.Address)

                {

                    Caption = 'Address';

                }

                field(address2; Rec."Address 2")

                {

                    Caption = 'Address 2';

                }

                field(city; Rec.City)

                {

                    Caption = 'City';

                }

                field(county; Rec.County)

                {

                    Caption = 'County';

                }

                field(postCode; Rec."Post Code")

                {

                    Caption = 'Post Code';

                }

                field(countryRegionCode; Rec."Country/Region Code")

                {

                    Caption = 'Country/Region Code';

                }

                field(phoneNo; Rec."Phone No.")

                {

                }

                field(email; Rec."E-Mail")

                {

                }


Now you have Microsoft Dynamics ready for Shiptheory, proceed to connecting Shiptheory and Microsoft Dynamics.