web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Recording the date when item inventory (quantity on hand) drops to 0 or below

(7) ShareShare
ReportReport
Posted on by 82
Is there a way we can record the date when the inventory (quantity on hand) of items drops to 0 or below? Since the inventory field on the item table is a FlowField, is there a way we can capture the before and after value anytime the inventory value changes on the item card? Please let me know if you have any suggestions on how to achieve this through a custom codeunit.
I have the same question (0)
  • Verified answer
    Sohail Ahmed Profile Picture
    10,983 Super User 2025 Season 2 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    @AK-13051749-0 

    That sounds like a clean and practical solution. Updating the “Last Depletion Date” directly on the item table when inventory drops to 0 or below makes it easy to filter and report on later. Just make sure you're checking for backdated entries so you don’t overwrite a more recent depletion date. Otherwise, it's a solid approach and should work well for what you need.

     

    ✅ Mark this answer as verified if it helps you.

  • AK-13051749-0 Profile Picture
    82 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    Thank you everyone. I appreciate all the responses.
     
    I am trying to record the date when an item quantity drops to 0 or below in a custom field called Last Depletion Date on the item table. The last depletion date will later be used as a filter on the item list and also on custom reports.
     
    I was able to deploy a solution by extending the Item Ledger Entry table with an OnAfterInsert trigger. Whenever a new item ledger entry gets created, the system checks the new quantity on hand for the item. If the quantity on hand is less than or equal to 0, then the Last Depletion Date on the item card gets updated with the posting date of the item ledger entry.
     
    Please let me know if you have any thoughts on this solution or have suggestions for alternative solutions.
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    6,939 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below

    Hi,

    Since the inventory field on the Item Card is a FlowField, it doesn’t store historical values directly, which makes tracking when quantity on hand drops to zero or below a bit tricky.

    Here’s what’s possible:

    • The best way to monitor inventory changes is by subscribing to the OnAfterInsertItemLedgerEntry event in a custom codeunit. This lets you intercept every new item ledger entry and check the remaining quantity after the transaction posts.
    • You can use CalcFields("Inventory") on the Item record to get the current quantity on hand. If the value is 0 or negative, log the SystemCreatedAt timestamp from the ledger entry along with the item number into a custom tracking table.
    • To avoid false positives, filter out entries that don’t affect quantity (e.g., reclassifications or cost adjustments). Focus on entries with Entry Type = Sale, Negative Adjmt., or similar.
    • Optionally, you can extend this logic to include location-specific tracking by checking the Item Ledger Entry.Location Code and aggregating quantities per location.


    Helpful references:

    Item Ledger Entries vs. Value Entries – Valentin Castravet
    Design Details: Inventory Periods – Microsoft Learn
    Advanced Inventory Management Features – D365 Training
    Inventory on Hand Reporting – ABCC Group
    Item Tracing and Tracking Setup – Dynamics 365 Lab


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • Suggested answer
    YUN ZHU Profile Picture
    90,068 Super User 2025 Season 2 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    If you want to strictly control it, why not disable negative inventory?
    More details: Prevent Negative Inventory
     
    If you want to record the date, you can refer to this standard function to record the date when the error is triggered.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
  • Suggested answer
    RockwithNav Profile Picture
    7,980 Super User 2025 Season 2 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    You can trigger this with an event or a certain customization but I would love to ask, What you are trying to achieve? Do you wish to maintain a certain stock always?
     
     
  • Suggested answer
    Ramesh Kumar Profile Picture
    7,503 Super User 2025 Season 2 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    Hi,
     
    Condition can be built using AL code (subscribing to item ledger entry creation events). But can you please help us understand what is business use case. 
     
    table 50100 "Item Inventory Events"
    {
        fields
        {
            field(1; "Item No."; Code[20]) { }
            field(2; "Event DateTime"; DateTime) { }
            field(3; "Event Type"; Option) { OptionMembers = Zero, Negative; }
        }
        keys { key(PK; "Item No.") { Clustered = true; } }
    }
     
     
    Thanks
    Ramesh
     
    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.
  • Gerardo Rentería García Profile Picture
    22,524 Most Valuable Professional on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    Hi
    You could consider a solution that uses write events to the Item Ledger Entry table to detect when inventory reaches zero and record the date in a custom table.
    Best
    GR
  • André Arnaud de Calavon Profile Picture
    297,389 Super User 2025 Season 2 on at
    Recording the date when item inventory (quantity on hand) drops to 0 or below
    Moved the question from the General to the Business Central forum. The words FlowField and Codeunit  indicates it is about Business Central or NAV.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,683 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,603

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,214

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans