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 :
Finance | Project Operations, Human Resources, ...
Answered

Null reference exception in Customer account statement report

(2) ShareShare
ReportReport
Posted on by 118
Hello everyone
I want to run a customer Account Statement report on D365 F&O(AccountReceivable > Inquiries & Reports > Customers > Customer Account Statement).

But it was not running  and giving me below error, i debugged the code so its giving me error from class - CustAccountStatementExtController, applyQueryRange Method(Line 2712). Its checking range in CustTable but we are not getting any range there, its null and then its throwing below error. 
1) The menu item with name custaccountstatementext could not be opened.
2) Object reference not set to an instance of an object.
 
As i didn't find anything by debugging the code, so I checked the event viewer and there is a error - 
Change Tracking must be enabled on database AXDB before it can be enable on GeneralJournalAccountEntry.
Change Tracking must be enabled on database AXDB before it can be enable on CustTable
Change Tracking must be enabled on database AXDB before it can be enable on DimensionAttributeValueCombination
When I tried to enable change tracking  from DMF, there also I am facing error - change tracking is not enabled on the database -sql server change tracking.
 
Then what i did:
Step 1) I went to Sql > Axdb's property(Change Tracking) and enabled it.
STep 2) Then i went to DMF > Configure entity export to Database - GeneralJournalAccountEntryEntity(Entity) and did change Tracking for(Enable Primary Table, Enable Custom Query), did same thing for CustTableChangeProposalFieldEnablementEntity(Entity).
Step 2) I repeat Step 2 from DMF > Data Entities also.
 
After above steps, now when i am opening report from frontend - error is same on front
1) The menu item with name custaccountstatementext could not be opened.
2) Object reference not set to an instance of an object.
But, in Event viewer it got changed to 
DimensionCombinationMissingMainAccount validation failed. Mitigation steps:  
Can anyone please help me on this.
 
Thanks in Advance.
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    236,275 Most Valuable Professional on at
    Null reference exception in Customer account statement report
    We've resolved the question why Object reference not set to an instance of an object. Now you have a new question to look at - why the report is called with a wrong query. Use the debugger to find more information.
  • D365_FO_Technical_Te Profile Picture
    118 on at
    Null reference exception in Customer account statement report
    Hi Martin,
     
    Thanks for the response.
     
    Yes, you are right. Qbds is empty and the query which is generating in backend doesn't has CustTable. Below query is generating in backend
     
    SELECT * FROM GeneralJournalAccountEntry(GeneralJournalAccountEntry_1) JOIN * FROM MainAccount(MainAccount) ON GeneralJournalAccountEntry.MainAccount = MainAccount.RecId;
    SELECT * FROM BudgetTransactionLine(BudgetTransactionLine_1) JOIN * FROM BudgetTransactionHeader(BudgetTransactionHeader_1) ON BudgetTransactionLine.BudgetTransactionHeader = BudgetTransactionHeader.RecId
     
     
    But, its a standard report, then it should have custTable in the query which is generating in backend.
    I checked AOT Query as well which are being used , query name is LedgerTransStatement and custTable is nowhere in the DataSource.
     
  • Verified answer
    Martin Dráb Profile Picture
    236,275 Most Valuable Professional on at
    Change Tracking issue
    Is this the code you're talking about?
    QueryBuildRange range = SysQuery::findOrCreateRange(qbds, fieldNum(CustTable, AccountNum));
    
    if (!range.value())
    It doesn't matter that you have no range on AccountNum; findOrCreateRange() will create it if it doesn't exist. I see the only reason why findOrCreateRange() may return null: when qbds is empty. Please use the debugger to verify if it's the case. By the way, you could have debugged findOrCreateRange() to see why it returned null.
     
    If qbds is empty, it means that the query doesn't contain CustTable data source at all. Such a query is not valid for this report.
     
    What you've found in events logs doesn't look related to the problem. Let me also change the thread title, because "Change Tracking issue" sounds unrelated to the actual topic.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,239

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 903 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 604 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans