Default Line Type behavior in Business Central

The Line Type Myth

Daniel Gorski
Daniel Gorski 07. Mai 2024
2 Min. Lesezeit

Are you looking to streamline your sales and purchase order processes? The "Document Default Line Type" feature in Business Central simplifies the way you manage document lines in both sales and purchases!

BUT: Just only for the very first line in the sales or purchase document! :-(

🔹 For Sales: You can now set your default line type directly in the "Sales & Receivables Setup". Whether it's items, resources, or G/L accounts, setting a default ensures consistency and speeds up order processing, allowing your sales team to focus more on selling and less on administrative tasks.

🔹 For Purchases: Similarly, in the "Purchases & Payables Setup", you can define the default line type for all new purchase orders. This means less time spent on configuring the first new line and more time optimizing your procurement strategy.

As you can see, if you insert the 2nd, 3rd or even more lines, the type is copied from your line above (called xRec):

To keep this behaviour in every line, we've provided a small code snippet in your own customization app:

\[EventSubscriber(ObjectType::Page, Page::"Sales Order Subform", 'OnBeforeSetDefaultType', '', false, false)\]
local procedure OnBeforeSetDefaultTypeSalesLine(var IsHandled: Boolean; var SalesLine: Record "Sales Line"; var xSalesLine: Record "Sales Line")
begin
    IsHandled := true;
    SalesLine.Type := SalesLine.GetDefaultLineType();
end;

\[EventSubscriber(ObjectType::Page, Page::"Purchase Order Subform", 'OnBeforeSetDefaultType', '', false, false)\]
local procedure OnBeforeSetDefaultTypePurchaseLine(var IsHandled: Boolean; var PurchaseLine: Record "Purchase Line"; var xPurchaseLine: Record "Purchase Line")
begin
    IsHandled := true;
    PurchaseLine.Type := PurchaseLine.GetDefaultLineType();
end;

And your new lines will be set to the default line type:

💡 By implementing these defaults, businesses can significantly reduce frustrations and increase efficiency. No more manual adjustments for every line item – just smooth, streamlined operations that enhance productivity and improve accuracy.

Checkout our Repo on Github:

https://github.com/byndit/BeyondAL

🔄 We recommend reviewing your current line item settings and considering how this feature can benefit your operations. If you have any questions or need assistance setting up this feature, feel free to reach out or comment below!

how-to
development
business central
sales lines
purchase orders
default line type
al development
E-Invoice Viewer for Business Central

New Open-Source E-Invoice Viewer for Business Central

View and convert German XRechnung XML files directly in Microsoft Dynamics 365 Business Central with the new open-source E-Invoice Viewer from BEYONDIT.

Weiter lesen
Weiter lesen
E-Invoice Viewer für Business Central

Neue Open-Source-App: E-Invoice Viewer für Business Central

Lesen und konvertieren Sie deutsche XRechnung-XML-Dateien direkt in Microsoft Dynamics 365 Business Central mit dem neuen Open-Source E-Invoice Viewer von BEYON

Weiter lesen
Weiter lesen