Skip to content
Default Line Type behavior in Business Central

The Line Type Myth: Default Line Types in Business Central

Daniel Gorski
Daniel Gorski May 07, 2024
3 min read

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! :-(

Sales & Receivables Setup page with the Document Default Line Type field open, showing Item selected among G/L Account, Item, Resource, Fixed Asset, Charge, and Allocation Account

🔹 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):

Sales order lines where a newly inserted line's Type field is highlighted as G/L Account, copied from the line above instead of defaulting to Item

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:

Sales order with a new line whose Type field now correctly defaults to Item, shown with the item lookup list open to select the number

💡 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!

Related posts

▸ All posts
AL runtime versions in Business Central

Business Central Runtime Versions List

February 06, 2024 · Daniel Gorski

Which AL runtime version belongs to which Business Central release, from runtime 1.0 (BC 12) to 16.0 (BC 27), and how to pick the runtime in app.json.

Read More
Read More: Navigating the Runtime Landscape in Business Central
Isolated Storage in Business Central report extensions

Using Isolated Storage on Report Extensions

June 15, 2022 · Daniel Gorski

Learn how to use Isolated Storage in AL report extensions in Business Central — and avoid a common casting error with a simple fix.

Read More
Read More: Using Isolated Storage on Report Extensions
Using OpenAI to write AL code for Business Central

Writing Business Central AL Code with ChatGPT

December 03, 2022 · Daniel Gorski

How OpenAI's ChatGPT helps Business Central developers write AL code – from a table design to a full page, and what you still need to adjust.

Read More
Read More: Writing code with a text-based AI for Business Central