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...
Suggested Answer

How to fix Value Entries dates?

(1) ShareShare
ReportReport
Posted on by 73
Hello,
 
I'm a developer and has been asked to fix the posting dates of our purchase and sale dates in order to fix the unit cost of our items.
I did a processOnly report to do so, but realize that after executing it when I look at the "Average Cost Calculation Overview" of an item, some lines no longer exist and some quantities have changed.
 
What would be your recommendations to fix that?
 
report 50104 "Value Entries Update"
{
    Caption = 'Value Entries Update';
    ProcessingOnly = true;
    Permissions = tabledata "Value Entry" = rimd;
 
    dataset
    {
        dataitem(ValueEntry; "Value Entry")
        {
            trigger OnAfterGetRecord()
            var
                SystemCreatedAtDate: Date;
                IsModified: Boolean;
            begin
                if ((ValueEntry."Item Ledger Entry Type" = "Item Ledger Entry Type"::Purchase) or (ValueEntry."Item Ledger Entry Type" = "Item Ledger Entry Type"::Sale)) then begin
                    SystemCreatedAtDate := System.DT2Date(ValueEntry.SystemCreatedAt);
                    IsModified := false;
                    if (ValueEntry."Valuation Date" <> SystemCreatedAtDate) then begin
                        ValueEntry.Validate("Valuation Date", SystemCreatedAtDate);
                        IsModified := true;
                    end;
                    if (ValueEntry."Document Date" <> SystemCreatedAtDate) then begin
                        ValueEntry.Validate("Document Date", SystemCreatedAtDate);
                        IsModified := true;
                    end;
                    if (ValueEntry."Posting Date" <> SystemCreatedAtDate) then begin
                        ValueEntry.Validate("Posting Date", SystemCreatedAtDate);
                        IsModified := true;
                    end;
                    if (IsModified) then
                        ValueEntry.Modify();
                end;
            end;
        }
    }
}
 
Thanks in advance,
Ludovic
I have the same question (0)
  • Suggested answer
    Dynamics_Decoded_Gokul Profile Picture
    451 on at
    How to fix Value Entries dates?
    Hi Ludovic, 

    Changing of this date will no longer helps in changing the unit cost of the Item since the Unit cost calculation. 

    How ever now you have did the correction in posting date so if you have back up revert the dates first. 
     
    post a revaluation journal for changing the cost of the item.
     
    Note: if Items are average costing this doesn't requires application but if its other case please select respective Item application entries to post the revaluations
     
    Thanks
    Gokulnath
  • Suggested answer
    YUN ZHU Profile Picture
    95,305 Super User 2025 Season 2 on at
    How to fix Value Entries dates?
    I totally agree with Gokulnath. Please never modify the Entry table directly from the AL code. This will cause many problems.
    If the purchase and sale dates are wrong, you should create a credit memo and then re-post the new one. There is no other shortcut.
     
    Hope this helps as well.
    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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans