Dynamics 365 Business Central: How to add Total Quantity, Number of Lines to the Sales Order List page – Customization

Dynamics 365 Business Central

Hi, Readers.
Today I would like to share a simple requirement, how to add Total Quantity, Number of Lines on the Sales Order List page.
This is a very common requirement. For example, in the Sales Order List, Microsoft has prepared a lot of Amount fields so that users can view some key information without opening the order.
For example,
Amout: Specifies the sum of amounts on all the lines in the document. This will include invoice discounts.

But I heard users ask more than once why there is no field for quantity or total number of Lines.😑
PS:
1. The total quantity can be found in Statistics (F7).

2. We’ve discussed how to add new fields to Total Area on the Document Subform page (View Total Quantity, Number of Lines on the Sales Order) before. At that time, the customization was done on the Sales Order page, but this time it needs to be on the list page.

Actually, this is not a difficult requirement, first let’s look at how the standard does it.
page 9305 “Sales Order List”:

table 36 “Sales Header”:

The standard is to use FlowFields to sum the Amount field on the Sales Lines. More details: Dynamics 365 Business Central: FlowFields (Sum, Average, Exist, Count, Min, Max, Lookup)
We can use the same way. For example,

Looks good.

Because it is a FlowField field, click on the value to open the record details.

Very simple, Give it a try!!!😁

PS: What I shared above is just an example of Sales Order List. You can also use the same way to add required fields to other pages.

Source code: Github

tableextension 50119 SalesHeaderExt extends "Sales Header"
{
    fields
    {
        field(50100; "Total Quantity"; Decimal)
        {
            Caption = 'Total Quantity';
            DecimalPlaces = 0 : 5;
            CalcFormula = sum("Sales Line".Quantity where("Document Type" = field("Document Type"),
                                                         "Document No." = field("No.")));
            Editable = false;
            FieldClass = FlowField;
        }
        field(50101; "Number Of Lines"; Integer)
        {
            Caption = 'Number Of Lines';
            CalcFormula = count("Sales Line" where("Document Type" = field("Document Type"),
                                                         "Document No." = field("No.")));
            Editable = false;
            FieldClass = FlowField;
        }
    }
}

pageextension 50119 SalesOrderListExt extends "Sales Order List"
{
    layout
    {
        addafter(Amount)
        {
            field("Total Quantity"; Rec."Total Quantity")
            {
                ApplicationArea = All;
            }
            field("Number Of Lines"; Rec."Number Of Lines")
            {
                ApplicationArea = All;
            }
        }
    }
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL