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

Notifications

Announcements

Community site session details

Community site session details

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

Sales Invoice Header amount is not showing

(0) ShareShare
ReportReport
Posted on by 410
hello all,
I am trying to sum amount of Sales Invoice Header table but it is returning 0 though amount exist. What is it? is it because flowfield? How i can get then another page?
        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;
  
I have the same question (0)
  • Suggested answer
    Genie Cetas Profile Picture
    472 on at

    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

  • Community Member Profile Picture
    on at

    And i suggest you to replace SaleInvoice.Init() to SaleInvoice.reset

  • Verified answer
    Asif Shahzad Profile Picture
    410 on at

    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.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

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 1,742

#2
YUN ZHU Profile Picture

YUN ZHU 844 Super User 2025 Season 2

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 719 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans