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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Posting Date

(0) ShareShare
ReportReport
Posted on by 4,824

Hi experts, how to show the last invoice posting date from the cust. ledger entry. I added the posting date on the report and it always shows the first invoice posting date.  Please advise! Thank yoU!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Posting Date

    Can you share us how you add the code in the report?

    You can set the current key based on posting date and then call FINDLAST. It will get you the last record of the record set.

  • snoppy Profile Picture
    4,824 on at
    RE: Posting Date

    Here is my code:


    IF ShowLastInvoice THEN BEGIN
    "Cust. Ledger Entry".SETRANGE("Document Type","Document Type"::Invoice);
    postingdate := "Cust. Ledger Entry"."Posting Date";

  • Suggested answer
    Jens Glathe Profile Picture
    6,092 on at
    RE: Posting Date

    Hi snoppy,

    two things:

    - You need a key like "Document Type,Customer No.,Posting Date" for the C/L entry. Posting date must be the last key element.

    - You need to perform a findlast (preferrably on a record variabe that is not your data item) to find the last invoice.

    You can also create a flowfield on the customer table for this. It would be more "oldschool NAV style"

    with best regards

    Jens

  • Suggested answer
    Tharanga Chandrasekara Profile Picture
    23,118 on at
    RE: Posting Date

    You can use below code sample :

    IF ShowLastInvoice THEN BEGIN
    
        CustLedgEntry.SETCURRENTKEY("Document Type",Posting Date");
    
        CustLedgEntry.SETRANGE("Document Type","Document Type"::Invoice);
    
        IF CustLedgEntry.FINDLAST THEN
    
            postingdate := CustLedgEntry."Posting Date";
    END;

    ** Check on the key because it will directly affect the performance of the report. 

    ** Use a separate record variable (not the report data item)

  • snoppy Profile Picture
    4,824 on at
    RE: Posting Date

    Thank you!

    Below is what I have done and there is an error when run the report.

      If "cust. ledger entry".FINDLAST THEN
         
           ShowLastInvoice := TRUE;
           
          IF ShowLastInvoice THEN BEGIN

        "cust. ledger entry".SETCURRENTKEY("Document Type","Posting Date");

       "cust. ledger entry".SETRANGE("Document Type","Document Type"::Invoice);

        IF "cust. ledger entry".FINDLAST THEN

            postingdate := "cust. ledger entry"."Posting Date";
    END;

    Error: The cust. ledge entry table does not have an active key that starts with the following field: document type, posting date.

    Please advise! Thank you!

  • snoppy Profile Picture
    4,824 on at
    RE: Posting Date

    I also tried to use the variable instead of the dataitem, but the posting date field is blank when run the report.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Posting Date

    Hello! You have to add key consisting of 2 fields "Document Type","Document Type" to table "cust. ledger entry" to  avoid error

    or

  • snoppy Profile Picture
    4,824 on at
    RE: Posting Date

    I tried this  "Cust. Ledger Entry".SETCURRENTKEY("Document Type","Document Type","Posting Date");

    But still not working. Please advise! Thank you!

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Posting Date

    You must change the table 21 object, not the code

    Open the table in Designer 

    Click View -> Keys

    Add corresponding key

    Which version of Nav do you use? 

  • snoppy Profile Picture
    4,824 on at
    RE: Posting Date

    Looks like it is working now. But when data are retrieved,  if there are lots of posting date related to the customer, it will show only one posting date, and hide the rest of them,  but there are lots of blank space and even some of them are page long. How to fix it? Thank you!

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans