web
You’re offline. This is a read only version of the page.
close
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

I want to show top five order amount customer in nav

(1) ShareShare
ReportReport
Posted on by 133
Documentation()
OnInitReport()
OnPreReport()
OnPostReport()
Sales Header - OnPreDataItem()
SalesHeader.GET();
FOR i:= 1 TO 5 DO BEGIN
  TopFiveAmount[i].Amount:=0;
SalesHeader.Amount:=0;
END;
SalesHeader.SETCURRENTKEY(Amount);
SalesHeader.SETASCENDING(Amount,TRUE);
i:=1;
IF SalesHeader.FINDSET THEN BEGIN
  REPEAT
    IF SalesHeader.Amount>TopFiveAmount[5].Amount THEN BEGIN
      TopFiveAmount[5].Amount:=SalesHeader.Amount;
      FOR i := 4 DOWNTO 1 DO BEGIN
        IF TopFiveAmount[i].Amount<TopFiveAmount[i+1].Amount THEN BEGIN
          TopFiveAmount[i+1]:=TopFiveAmount[i];
          TopFiveAmount[i]:=TopFiveAmount[i+1];
          END;
        END;
      END;
    UNTIL SalesHeader.NEXT=0;
  END;
 
Sales Header - OnAfterGetRecord()
Sales Header - OnPostDataItem()
 
 
 
When I run this report this msg will shown can you please help me solve .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
I have the same question (0)
  • KasparsSemjonovs Profile Picture
    4,774 Super User 2025 Season 2 on at
    You would need to add a filter to Document Type = Order
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    Hi, I think it will be much easier for you to create a Query.
     
     
    Hope this helps as well.
    Thanks.
    ZHU
  • AjayPandey Profile Picture
    133 on at
    Hi all I am using repeat but still it is not working 
     
     
     
  • AjayPandey Profile Picture
    133 on at
    I have already add a filter to Document type=Order  after apply filter it  shows only order of the customer in the reports.
    but i want last two order amount of all customer. mentioned below is the code ,
     
    Sales Header - OnPreDataItem()
    "Sales Header".SETCURRENTKEY("Document Date","Document Type");
    "Sales Header".SETRANGE("Document Type","Sales Header"."Document Type"::Order);
    "Sales Header".CALCFIELDS(Amount);
    "Sales Header".SETFILTER(Amount,'<>0');
    "Sales Header".SETASCENDING("Document Date",FALSE);
      NoOfOrder:=0;
      IF OrderAmount=0 THEN 
        REPEAT
        NoOfOrder:=NoOfOrder + 1;
          IF NoOfOrder=2 THEN BEGIN
            END;
      UNTIL ("Sales Header".NEXT=-1) OR (NoOfOrder=2);
      

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 2,362

#2
YUN ZHU Profile Picture

YUN ZHU 867 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans