community postSales & Receivablescommunity - not Microsoftreviewed - checked by Opus

Dynamics 365 Business Central: How to show a warning about low inventory on a sales document (Prohibit users from adding sales lines with low inventory)

Business Central offers a built-in Stockout Warning toggle to notify users when sales document quantities exceed inventory levels. For stricter control, customization using codeunit 311 event subscribers can prevent sales line creation when inventory is insufficient.

post Dynamics 365 Lab

Yun Zhu · 2025-05-23 · 437 words · about 2 min

"The notification is just to inform them of the potential problem, and doesn't prevent them from creating the order or posting the order."

Key points

  • Enable Stockout Warning in Sales & Receivables Setup to display notifications when inventory goes negative
  • The standard warning only informs users and does not prevent order creation or posting
  • Prohibit users from adding sales lines with low inventory by subscribing to the OnShowWarningOnAfterCalculate event in codeunit 311
  • Custom code can raise an error to block sales line entry when available inventory plus net change is negative

Quotes

  • “The notification is just to inform them of the potential problem, and doesn’t prevent them from creating the order or posting the order.” (Clarifies the limitation of the standard feature and the need for customization to enforce restrictions)
  • “If you want to prohibit users from adding sales lines with low inventory, this can only be done through customization as of now.” (Explains when and why developers need to implement custom code using event subscribers)

AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

Not found in BC28-30: codeunit “ItemAvailabilityHandler”.

Context

  • Features: Stockout Warning, availability check, inventory notifications, sales document validation

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.