Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Answered

Code to fetch customer balance on basis of asOfdate parameter

Posted on by 23
Hello,
 
Can anyone help me, how can we fetch the Customer Balance amount on basis of date like asOfdate.
 
 
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    Code to fetch customer balance on basis of asOfdate parameter
    By the way, there is no need for a while select, because your query won't ever return more than a single record. It summarizes all records together (without any grouping). Therefore your code can be refactored to this:
    select sum(AmountMST) from custTrans
        where custTrans.AccountNum == custTable.AccountNum
           && custTrans.TransDate <= balDate;
           
    balanceTmp.BalAmount = custTrans.AmountMST; // Total Balance
    balanceTmp.OpeningBalance = custTable.openBalanceMST(balDate);
  • Suggested answer
    Nikita Mhamane Profile Picture
    Nikita Mhamane 23 on at
    Code to fetch customer balance on basis of asOfdate parameter
    Hello Everyone,
     
    Thank you for the response!!
     
    I got the solution as -
     
      while select sum(AmountMST) from custTrans
                 where custTrans.AccountNum == custTable.AccountNum
                 && custTrans.TransDate <= balDate
            {
                BalanceTmp.BalAmount = custTrans.AmountMST; // Total Balance
            }
                BalanceTmp.OpeningBalance = custTable.openBalanceMST(balDate);
  • Hana Xue Profile Picture
    Hana Xue Microsoft Employee on at
    Code to fetch customer balance on basis of asOfdate parameter
    Hi Nikita,
    You can refer to the code shown in the screenshot, it may not be accurate, but you can refer to it to get inspiration.
    In this code, first specify the "asOfDate" and then select the sum of the field from records for the specified customer () where the transaction date is less than or equal to the "asOfDate."

    Best Regards,
    Hana
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    Code to fetch customer balance on basis of asOfdate parameter
    Hi Nikita,
     
    You can sum all CustTrans records per customer setting a range on the transaction date. 
  • Nikita Mhamane Profile Picture
    Nikita Mhamane 23 on at
    Code to fetch customer balance on basis of asOfdate parameter
    Hello hana,
     
    The link is not working for me.
  • Hana Xue Profile Picture
    Hana Xue Microsoft Employee on at
  • Nikita Mhamane Profile Picture
    Nikita Mhamane 23 on at
    Code to fetch customer balance on basis of asOfdate parameter
    Thank you for the reply.
     
    Yes ,both the threads are from D365 F&O.
     
    I will move this to finance forum.
  • Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    Code to fetch customer balance on basis of asOfdate parameter
    I see that code in your other thread is actually from D365 F&O, not Dynamics AX. Isn't this question about F&O 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

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans