Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

How to create totals for each vendor in a list page

Posted on by 5,124

Hello Experts!  I want to customize the Payment Journal List Page so that I also show the Total Amount for each vendor at the bottom of the page.  I believe we can achieve this by creating a Group right after the repeater.  But I am having a tough time summing up the Gen. Journal Line.Amount (this is the source for Payment Journal) for each vendor.  Note that a vendor may be listed more than once as it may have purchase Invoices that need to be paid.  IS there an easy way to make this happen?  Currently I have a function I call in the source expr of the Group Field for Vendor.  This function will make a copy of the Source (go through repeat until all records are copied) and then sum up only the ones where account no = the Vendor in question.  This is ugly as it could slown down the performance.  I also don't know how to get back to the cursor where the user clicked onto. :(  Please help!

Also, can you advise how I can change the background to a different color depending on the Total Amount calculated in the group section?

Thank you thank you in advance

*This post is locked for comments

  • mbr Profile Picture
    mbr 5,124 on at
    RE: How to create totals for each vendor in a list page

    Hi Suresh,  I have been researching and I realized I am not supposed to update any fields in the ONAFTERGETRecord as they don't really get reflected onto the Table right away.....but for the requirements I almost don't have a choice.  Basically, depending on the total amount for ea vendor, its corresponding record (and there could be > 1 record associated with that vendor) will either have a check on the custom field or not.  In any case, I found a workaround....not very pretty as I ended up creating a temptabl that monitors the changes so I can evaluate later on Post.  But any suggestions from you on how to manipulate fields (modify) in the ONAfterGetRecord trigger would be great.  Note that I have to use ONAfteGetRecord as users may not necessarily go to that record but would need to see the check mark regardless.

  • mbr Profile Picture
    mbr 5,124 on at
    RE: How to create totals for each vendor in a list page

    Hi Suresh,

    Sorry, I wasn't clear with my original requirements! :)  I needed to have all the records in the list actually also show a check mark or not depending on the total amount for each vendor.  I.e., users have to see them on the list as checked or unchecked (each record) plus also show the total amount as they go through the  records.  So I ended up calling the function in the ONAfterGetRecord.  I may tweak it more to separate the function and call in the onaftergetrecord as well as onaftergetcurrRecord.  Much obliged!  The problem I have now is when I update the field in the onaftergetrecord, it doesn't really save to the table and so if I iterate through the record (table) on push of a button, the changes I made in the onaftergetrecord are not reflected.  Huhu! more problems.  Thoughts?

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: How to create totals for each vendor in a list page

    Sorry but i am still confused about your cursor question. You will calculate the totals as user moves from one record to another and you will select the record (Rec) which is normally where the cursor is on and use that to filter vendor no.

  • mbr Profile Picture
    mbr 5,124 on at
    RE: How to create totals for each vendor in a list page

    Hi suresh! Yes, i plan to mimic what updatebalance does which is being called in aftergetcurrRecord. The only obstacle i face is the dataset i want to filter and calc total amt is the record itself. So when i am done calculating, the cursor is not on the same position anymore. How do i go back to the same cursor position prior to calling my function? My workaround was copying everything into a temp table before calc total amount. But i feel that i am sacrificing performance.

    Pls advise!

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: How to create totals for each vendor in a list page

    Are you planning to show all the vendor no. and amount every time ? if not and if you plan to update total amount based on the selected record then you don't need your function to loop through all the records you just need to filter for the Vendor No. of the selected record and call your function on the OnAfterGetCurrRecord/OnOpen as it currently does now in the payment journal page to calculate other balances.

    I don't believe you can change the background, you can change the text color using styleexpr .

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

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

Featured topics

Product updates

Dynamics 365 release plans