Announcements
No record found.
Var SaleInvoice: Record "Sales Invoice Header"; amount: Decimal; TempDate: Date; Begin TempDate: Today; SaleInvoice.Init(); SaleInvoice.SetFilter("Posting Date", format(CALCDATE('<-CM>', TempDate)) '..' format(calcdate('', TempDate))); if SaleInvoice.FindSet() then begin repeat //Message('Sales Amount: ' format(SaleInvoice.Amount)); amount = SaleInvoice.Amount; until SaleInvoice.Next() = 0; end; Message('Sales Total: ' format(amount)); End;
Hi Asif,
The Amount in Sales Invoice Header is flowfield. You must use either CalcFields or SetAutoCalcFields to retrive the value for FlowFields.
I have corrected your code.
Var SaleInvoice: Record "Sales Invoice Header"; amount: Decimal; TempDate: Date; Begin TempDate: Today; SaleInvoice.Init(); SaleInvoice.SetFilter("Posting Date", format(CALCDATE('<-CM>', TempDate)) '..' format(calcdate('', TempDate))); if SaleInvoice.FindSet() then begin repeat //Message('Sales Amount: ' format(SaleInvoice.Amount)); SalesInvoice.CalcFields(Amount); //Genie - Added amount = SaleInvoice.Amount; until SaleInvoice.Next() = 0; end; Message('Sales Total: ' format(amount)); End;
For more information about CalcFields & SetAutoCalcFields :
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-calcfields-method
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-setautocalcfields-method
And i suggest you to replace SaleInvoice.Init() to SaleInvoice.reset
Thank you Genie, It works.
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
OussamaSabbouh 2,091 Super User 2026 Season 1
YUN ZHU 1,032 Super User 2026 Season 1
Dhiren Nagar 946 Super User 2026 Season 1