Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Expiration Date must not change for an item tracked by lot number

Posted on by
Since the release of BC23 SaaS, there's an issue with the OnValidate() of the Expiration Date field in the Warehouse Journal Line.
 
We have some custom code to fill in the Warehouse Journal at a certain moment of time (with scanner functionality), and we use a Validate() of the Expiration Date.
In BC22, there was no issue when using a 0D as Expiration Date to do this. However, in BC23, an error occurs when doing this:
/Expiration Date must not change for an item tracked by lot number./
 
In BC22, there was no code in the OnValidate() trigger of the /Expiration Date/ field on the Warehouse Journal Line. Now, in BC23, there is 1 line of code:
CheckLotNoTrackedExpirationDate();
 
Besides the fact that it's not initializing /Item Tracking Setup/ anywhere but using it, there's an other issue:
In some point of time, when you dig deeper into the next functions that are called, the following function is called:
ItemTrackingManagement.GetWhseExpirationDate(...)
This function is NOT doing/checking correct on Expiration Date. It only checks if there's an Item Ledger Entry which is Positive, and then returns TRUE, which results eventually in the error /Expiration Date must not change for an item tracked by lot number./. Since the expiration date is filled with 0D, the error should not occur (because there were NO entries with an Expiration Date, and the journal line also will have no Expiration Date).
 
To fix this, the code in Item Tracking Management, and also the functions ExistingExpirationDate() and WhseExistingExpirationDate() should be reviewed.
Both functions just check if there are entries (Item Ledger Entries for the first one, Warehouse Entries for the second one). For both functions, IF there are Item Ledger Entries / Warehouse Entries for the item, the /EntriesExist/ will be TRUE.
So the result will be that it exits with the first function already, and with an ExpiryDate = 0D. This will result in an error in CheckLotNoTrackedExpirationDate() in the Warehouse Journal Line:
 
In my opinion, there should be a little code change in GetWhseExpirationDate(), namely:
change:
        if EntriesExist then
            exit(true);
into:
        if EntriesExist and (ExpiryDate <> 0D) then
            exit(true);
 
In that case, there will be no exit(true), but just continuing and getting to the next code:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,647 Super User 2024 Season 2 on at
    Expiration Date must not change for an item tracked by lot number
    Hi, if you think there is a problem with the standard function, you can try submitting it to the following two places.
     
    Hope this helps.
    Thanks.
    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans