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

using sql query trying to find related invoice no for a credit memo

(0) ShareShare
ReportReport
Posted on by 30

I am using SQL queries into Nav 2017 to pull data out for PowerBI reports. I'm trying to find the related records for credit memos.

I can clearly see in NAV on the About This Page - Applied Customer Entries (Page: Applied Customer Entries (61)) that it is using the Source Table Cust. Ledger Entry (21) and there is a Field for Document Type = Invoice and Document No = 322233 (the invoice the credit memo is applied to), but when I go to the SQL table [...Cust. Ledger Entry] neither the Document Type and Document No fields are there.

Well not quite true of the Document No, that is in the table but it is the Credit Memo Document No not the Invoice No.

Below is a screen shot of the About This Page, but can't find those two fields in the SQL Table [...Cust. Ledger Entry]

I found a few examples of this were the About This Table Fields is listing fields that are not in the actual SQL table, clearly there is a relationship that i'm not seeing.

applied-cust-entries.jpg

It is even stranger, when I query the above table with the statement below I get zero results


SELECT *
FROM [dbo].[xxx$Cust_ Ledger Entry]
WHERE [Applies-to Doc_ No_] = '322233'

I have the same question (0)
  • Gearoid Profile Picture
    on at

    Hi,

    The following works for me in the Standard Cronus (DE) database:

    SELECT *

    FROM [dbo].[CRONUS AG$Cust_ Ledger Entry]

    WHERE [Document No_] = '103005'

    and [Document Type] = 2 -- 2=Invoice

    Hope that helps!

  • RockwithNav Profile Picture
    8,600 Super User 2025 Season 2 on at

    Transaction no will help you out!!

  • Suggested answer
    dvcoop Profile Picture
    30 on at

    Okay, figured out what the issue is.

    Unless at the time of the credit memo creation the user enters which invoice it applies to, there will be no entries in the [Applies-to Doc_ No_] field for the Credit Memo Customer Ledger entry.

    What I found is that in the Invoice related Customer Ledger record there is a [Closed by Entry No_] that points back to the Credit Memo Customer Ledger entry.

    So you basically just left join the Cust_ Ledge Entry] table to itself referencing the [Closed by Entry No_]

    SELECT

    *

    FROM [dbo].[xxx$Cust_ Ledger Entry] as CL

    LEFT JOIN [dbo].[xxx$Cust_ Ledger Entry] as CB ON CL.[Entry No_]=CB.[Closed by Entry No_]

    WHERE CL.[Document Type] = '3'

    So the above query will give you all the credit memos and the records they relate back too.

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 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans