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
Visualisierung von Hauptbuch und Nebenbuch in Business Central

Hauptbuch und Nebenbuch in Business Central: So hängt alles zusammen

Hauptbuch, Nebenbuch, Buchungsgruppen – klingt trocken, ist aber das Fundament jeder sauberen Buchhaltung in Business Central. Wer hier nicht durchblickt, verli

Read More
Read More
Modulare ERP-Architektur für skalierbare Unternehmenssoftware

Warum ERP erst dann wirklich skalierbar wird, wenn es modular gedacht wird

ERP-Systeme gelten als stabiles Rückgrat moderner Unternehmen. Doch die Realität zeigt: hohe Komplexität, starre Strukturen und teure Anpassungen. Die Lösung? M

Read More
Read More