Announcements
No record found.
Hello everyone,
I’m working on an integration project in D365 FO where I need to pull and store trial balance data from the standard Trial Balance feature located under General Ledger > Inquiries and Reports. I want to extract this data into a custom table (NPLLedgerTrialBalance) so I can send it through Data Entity. I am using the LedgerTrialBalanceDP class along with a contract (LedgerTrialBalanceContract) to filter data by fiscal period and fiscal year. Additionally, I am pulling DisplayMainAccountCategory from a parameter field in D365.
NPLLedgerTrialBalance) so I can send it through Data Entity
LedgerTrialBalanceDP
LedgerTrialBalanceContract
DisplayMainAccountCategory
Below is a shortened version of my code
public void trialBalance(FiscalCalendarPeriod calendarPeriod) { NPLLedgerTrialBalance _TrialBalance = null; LedgerTrialBalanceTmp _ledgerTrialBalanceTmp = null; TransDate iniDate = calendarPeriod.StartDate; TransDate endDate = calendarPeriod.EndDate; List postingLayers; // Update dimension focus balance DimensionFocusUpdateBalance::updateBalance(DimensionHierarchy::findByTypeAndName(DimensionHierarchyType::Focus, "MA + Brand + Location + Dept")); // Posting layers postingLayers = new List(Types::Enum); postingLayers.addEnd(CurrentOperationsTax::Current); // Contract setup LedgerTrialBalanceContract trialBalanceContract = new LedgerTrialBalanceContract(); trialBalanceContract.parmFromDate(iniDate); trialBalanceContract.parmToDate(endDate); trialBalanceContract.parmIncludeOpening(true); trialBalanceContract.parmIncludeClosingAdjustments(true); trialBalanceContract.parmIncludeClosingTransactions(true); trialBalanceContract.parmPostingLayers(postingLayers); trialBalanceContract.parmPrimaryDimensionFocus(LedgerParameters::find().NPLDimensionSetName); trialBalanceContract.parmDisplayMainAccountCategory(true); // Process data LedgerTrialBalanceDP trialBalanceDP = new LedgerTrialBalanceDP(); trialBalanceDP.parmDataContract(trialBalanceContract); trialBalanceDP.processReport(); // Iterate over LedgerTrialBalanceTmp and insert into NPLLedgerTrialBalance _ledgerTrialBalanceTmp = trialBalanceDP.getLedgerTrialBalanceTmp(); while select _ledgerTrialBalanceTmp { _TrialBalance.clear(); _TrialBalance.AmountCredit = _ledgerTrialBalanceTmp.AmountCredit; _TrialBalance.EndingBalance = _ledgerTrialBalanceTmp.EndingBalance; _TrialBalance.NetChange = _ledgerTrialBalanceTmp.NetChange; _TrialBalance.insert(); } }
The form is pretty basic, so I expect the method to return the same values. Are you sure you are calling it with the exact same values in contract as the form?
One thing that comes to mind is that your code might be forcing the use of the old trial balance calculation and not considering the feature for the optimized trial balance calculation. I'd recommend you use LedgerTrialBalanceTmp::calculateBalances_V2 instead of using LedgerTrialBalanceDP directly.
LedgerTrialBalanceTmp::calculateBalances_V2
Hello Jonas,
Thank you for your suggestion, you were right! I used the calculateBalances_V2 method directly and passed all the parameters instead of using the DP, and it worked like a charm! I appreciate your help!
calculateBalances_V2
Best, Mario C.
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.
Congratulations to our community stars!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 495 Most Valuable Professional
André Arnaud de Cal... 432 Super User 2026 Season 2
CU10121822-0 366