Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

New action to Sum all amounts filtered on Sales Order List page

Posted on by 160

Hi mates! :)

I need your help, I created a button on Sales Order List that count all the records (it's ok) and now, I need another one that sum all the amounts of the filtered records.

Something like:

Order 1 -> 20

Order 2 -> 40

Order 4 -> 10

Pressing button (action) and --> Total Amount: 70

pastedimage1646663234924v1.png

Is there any way to do that?

Thanks a lot :)

  • JMartin Profile Picture
    JMartin 160 on at
    RE: New action to Sum all amounts filtered on Sales Order List page

    Thanks Lars!

    That worked :D

  • Verified answer
    RE: New action to Sum all amounts filtered on Sales Order List page

    Hello, just an example below. It is wrong at least on one point that it is totalling Amount, not Amount (LCY), so it will total $, £, etc alike. But I hope it gives you some ideas where to start:

    pageextension 50101 OrderTotals extends "Sales Order List"

    {

       layout

       {

           // Add changes to page layout here

       }

       actions

       {

           addfirst("F&unctions")

           {

               action(GetTotal)

               {

                   ApplicationArea = all;

                   Caption = 'Get Total';

                   trigger OnAction()

                   var

                       SalesHeader: Record "Sales Header";

                       Total: Decimal;

                   begin

                       Total := 0;

                       SalesHeader.copy(Rec);

                       if SalesHeader.FindSet() then

                           repeat

                               total := total + SalesHeader.Amount;

                           until SalesHeader.Next() = 0;

                       Message(Format(Total));

                   end;

               }

           }

           // Add changes to page actions here

       }

       var

           myInt: Integer;

    }

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 51,686 Super User on at
    RE: New action to Sum all amounts filtered on Sales Order List page

    You can start from here

    docs.microsoft.com/.../devenv-dev-overview

  • JMartin Profile Picture
    JMartin 160 on at
    RE: New action to Sum all amounts filtered on Sales Order List page

    Hi Mohana :)

    How can I do that?

    Thanks! :)

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 51,686 Super User on at
    RE: New action to Sum all amounts filtered on Sales Order List page

    You can loop through all orders and assign the Amount a Sum variable and display the message at the end.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans