Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

I want to print in the report last two order amount of all customer in nav.

Posted on by 133
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);
  
  • AjayPandey Profile Picture
    AjayPandey 133 on at
    I want to print in the report last two order amount of all customer in nav.
    When i run this code it cant shows first two order amount of customer , it shows the all order amount of customer in the report. can you please suggest me what can i do .
     
     
    Documentation()
    OnInitReport()
    OnPreReport()
    OnPostReport()
    Sales Header - OnPreDataItem()
    "Sales Header".SETCURRENTKEY("Document Date","Document Type");
    "Sales Header".SETRANGE("Document Type","Sales Header"."Document Type"::Order);
    "Sales Header".SETRANGE("Sell-to Customer No.",'60000');
    "Sales Header".CALCFIELDS(Amount);
    "Sales Header".SETFILTER(Amount,'<>0');
    "Sales Header".SETASCENDING("Document Date",TRUE);
      LastTransactionCount:=0;
      IF "Sales Header".FINDFIRST THEN
      REPEAT
        LastTransactionCount:=LastTransactionCount +1; 
        OrderAmount:="Sales Header".Amount;
        UNTIL (LastTransactionCount=2) OR ( "Sales Header".NEXT=0);
    Sales Header - OnAfterGetRecord()
    Sales Header - OnPostDataItem()
     
  • AjayPandey Profile Picture
    AjayPandey 133 on at
    I want to print in the report last two order amount of all customer in nav.
    I want to print only last two transaction of customer 
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,698 Super User 2024 Season 2 on at
    I want to print in the report last two order amount of all customer in nav.
    Hi, what is your problem now?
    I think it is more convenient to use Query. More details: https://learn.microsoft.com/en-us/dynamics-nav/topnumberofrows-function
     
    Hope this helps.
    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans