Skip to main content

Notifications

Announcements

No record found.

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
  • Suggested answer
    YUN ZHU Profile Picture
    78,972 Super User 2025 Season 1 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
  • Suggested answer
    Tech_BC_Gokul Profile Picture
    331 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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,020 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans