Techno-functional Dynamics 365 F&S Data Model Explanations for Reporting, Part 7 of 25 – Sales Order Creation Process

Techno-functional Dynamics 365 F&S Data Model Explanations for Reporting, Part 7 of 25 – Sales Order Creation Process

Things have changed a lot since I started blogging over a decade ago. There are so many wonderful topics to blog and learn on today; it seems like one doesn’t even know where to start. To make the process more friendly, I’ve introduced a new sort of techno-functional blog tutorial. In this series, some very talented developers from my team have contributed their expertise to assist with this content approach to ensure that we keep our quality and quantity high. I hope you all sincerely enjoy the new approaches that we’ve innovated.. And as always, don’t hesitate to reach out to me.. I’m always here to help. — Brandon Ahmad

 

Dynamics 365 Sales Order Creation

Today, we’re going to look at one of the most frequently customized processes in Dynamics 365 – sales order creation. Learning the functional and technical processes for creating sales order can be daunting at first, but we’re going to break it down step-by-step and take the mystery out with this tutorial. We will begin with the basic functional process before getting into the technical part of the process. You will be pleased to see impressive data model functionality, amazing ERDs, and tables.

Now let’s move on to creating a sales order.

How to Create Dynamics 365 Sales Order Manually: Functional Walkthrough

Dynamics 365 Sales Order

Step 1

First, locate the icon  in the upper left corner of your D365 client. Then navigate to ‘All sales orders’ by clicking on ‘Modules’ > ‘Accounts receivable’ > ‘Orders’ > ‘All sales orders.’

Dynamics 365 Sales Order - Step 1

Step 2

After that, locate the ‘+New’ tab at the top left corner and click it. This will direct you to ‘Create sales order’.

Dynamics 365 Sales Order - Step 2

Step 3

Locate the ‘Customer account’ field and select any value. After that, its associated information will auto-populate the rest of the sales order header. For the purpose of learning, here we have used the standard Contoso machine as an example.

Dynamics 365 Sales Order - Step 3

Step 4

Now click ‘OK’ to create the sales order.

Dynamics 365 Sales Order - Step 4

 

If you are a developer wishing to learn more, it may be wise to check out our Boot Camp, which takes you from zero to hero with some serious hands-on lab action.

Dynamics 365 training courses

Step 5

Now you will be directed to the following display. Click on the ‘Item number’ field and choose any item for your sales order line item.

Dynamics 365 Sales Order - Step 5

Step 6

You can see that the default quantity is auto-populated in the quantity field, else you can enter any quantity value. Now go to Line details tab, select ‘Product’ section and enter the required Site and Warehouse values.

Dynamics 365 Sales Order - Step 6

Step 7

Finally, click on Confirm sales order to validate that the sales order is legitimate and acknowledged as a valid sales order.

Dynamics 365 Sales Order - Step 7

Now, we will move on to the technical part of creating a sales order.

The Data Model Behind Dynamics 365 Sales Order Creation: Technical Walkthrough

We focused on the basic functional process and now we are going to move on to the technical part of creating a sales order.

Entity Relationship Diagram for Creating Dynamics 365 Sales Order

These are some of the important tables involved in creating sales order in Dynamics 365. You can see the primary tables and the cardinality constraints with ‘InventSite’ and ‘InventLocation’

Dynamics 365 Sales Order - ERD

Below you will see a Runnable Class (job) to create the Sales Order by getting the next number sequence of the Sales Order:

// Using USP2 Contoso Company for sample data.
class ibCreateSalesOrder
{
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        NumberSeq numberSeq;
        SalesTable salesTable;
        SalesLine salesLine;
        ttsBegin;
        numberSeq = NumberSeq::newGetNum(
            SalesParameters::numRefSalesId());
        numberSeq.used();
        salesTable.SalesId = numberSeq.num();
        salesTable.initValue();
        salesTable.CustAccount = 'US-020'; // using data from USP2 contoso legal entity
        salesTable.initFromCustTable();
        if (!salesTable.validateWrite())
        {
            throw Exception::Error;
        }
        salesTable.insert();
        salesLine.SalesId = salesTable.SalesId;
        salesLine.ItemId = 'M6008'; // using data from USP2 contoso legal entity
        salesLine.createLine(true, true, true, true, true, true);
        ttsCommit;
        info(strFmt("Sales order '%1' has been created", salesTable.SalesId));
    }
}

Although there are many tables included in this process, we’re going to focus on two major tables. The two major tables we will focus on are ‘SalesTable’ and ‘SalesLine.’ Let’s go ahead and start with SalesTable.

SalesTable:

This table stores the header information of the Sales Orders and is also called a ‘master table’ for this process in Dynamics 365. This table is extremely useful in Dynamics 365. Let’s have a look at some types of data SalesTable contains:

  • It has customer account details which include customer balances and transactions.
  • The return orders including updates are processed through this table.
  • Simulated delivery dates are helpful to get the available ship and receipt dates, SalesTable have the reference for Simulated delivery dates.

Below, we have listed down other significant fields of the SalesTable along with their respective descriptions.

FieldData TypeDescription
SalesIdstringUnique numeric sales order Id, it is also primary key
SalesNamestringPurchase order name
ProjIdstringAssociated project Id, if any
SalesStatusEnumSales Order status  (Open order, Received, Cancelled or Invoiced)
InventLocationIdstringUnique id for the location for which Sales Order is created
InventSiteIdstringUnique id for Site of location
DeliveryDatedatetimeDelivery date for the sales order
DeliveryNamestringTitle of default Delivery address for customer

Now let’s take a look at SalesLine.

SalesLine:

The line details of Sales Order are populated in this table, and we can get all the information we added in the Sales Order lines view earlier. Let’s have a look at some characteristics of the SalesLine table:

  • Contains item id with product name and variant number
  • Multiple lines of single item orders can be stored in the SalesLine table
  • SalesLine contains frequently used data for reports such as discounts, taxes, and quantity of past sales of specific items.

Next we will show you a few of the important fields of this table along with the description.

FieldData TypeDescription
ItemIdstringUnique numeric Item Id
SalesStatusEnumSales Order status (Open order, Received, Cancelled or Invoiced)
TaxGroupstringForeign key to look up Tax Group
TaxItemGroupstringForeign key to look up Tax Item Group
SalesQtyintQuantity of Itemid to be sold
CustAccountstringForeign key to look up Customer Account

Overview:

In this post, we:

  • covered creating a sales order in Dynamics 365 F&S
  • reviewed the technical side of creating a sales order
  • discussed two major tables: SalesTable and SalesLine
  • discussed ways in which to use both tables.
We sincerely hope that you enjoyed part 7 of our exciting series on the Dynamics 365 data model. We aim to provide quality service at all times.  And as always, if you need to reach me, you know how to get in touch by reaching out to me here.  — Brandon Ahmad, founder of InstructorBrandon and Dynatuners.

Leave a Reply

Your email address will not be published. Required fields are marked *