Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Prev Day Sale on Role Center

Posted on by 190

Hello,

am trying to bring Previous Day Sale into the Cue Activites. pls correct if am doing wrong. right now am not getting it

pageextension 60102 "Last Day Sale" extends "O365 Activities"
{

    Caption = 'Activities';


    layout
    {
        // Add changes to page layout here
    }
    actions
    {

    }
}
    cuegroup(Control54)
            {
                CueGroupLayout = Wide;
                ShowCaption = false;
                field("Previous Day Sale";Rec.Preious Day Sale);
                {
                    ApplicationArea = Basic, Suite;
                    DrillDownPageID = "Posted Sales Invoices ";
                    ToolTip = 'Specifies the sum of sales in the Last Working Day';

                    trigger OnDrillDown()
                    begin
                        ActivitiesMgt.DrillDownPostedSalesInvoice;
                    end;
                }
}

}

  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,056 on at
    RE: Prev Day Sale on Role Center

    Hi,

    You can write the below logic .

    Page 60113 "LastDaySale"

    {

       PageType = CardPart;

       RefreshOnActivate = true;

       layout

       {

           area(Content)

           {

               cuegroup(cuegroup1)

               {

                   Caption = 'Previous Day Sale';

                   field(LastDaySale; LastDaySalevar)

                   {

                       Caption = 'Prev Day Sale';

                       ApplicationArea = All;

                       StyleExpr = Style;

                       Lookup = true;

                       trigger OnDrillDown()

                       var

                           CustLedEntry: Record "Cust. Ledger Entry";

                           CustLedEntrylist: Page "Customer Ledger Entries";

                           CustLedEntry1: Record "Cust. Ledger Entry";

                       begin

                           Clear(CustLedEntry);

                           CustLedEntry.Reset();

                           Clear(CustLedEntry1);

                           CustLedEntry1.Reset();

                           Clear(CustLedEntrylist);

                           CustLedEntry.SetCurrentKey("Posting Date", "Global Dimension 1 Code");

                           CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');

                           CustLedEntry.SetAscending("Posting Date", false);

                           // CustLedEntry.SetRange("Posting Date", CustLedEntry."Posting Date");

                           IF CustLedEntry.FindFirst() THEN BEGIN

                               CustLedEntry1.SetRange("Posting Date", CustLedEntry."Posting Date");

                               CustLedEntry1.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');

                               CustLedEntrylist.SETTABLEVIEW(CustLedEntry1);

                               CustLedEntrylist.Run();

                           end;

                       end;

                   }

               }

           }

       }

       trigger OnAfterGetCurrRecord()

       var

           CustLedEntry: Record "Cust. Ledger Entry";

           CustLedEntry1: Record "Cust. Ledger Entry";

           CustLedEntrylist: Page "Customer Ledger Entries";

       begin

           Clear(CustLedEntrylist);

           Clear(CustLedEntry);

           CustLedEntry.Reset();

           Clear(CustLedEntry1);

           CustLedEntry1.Reset();

           Clear(LastDaySaleVar);

           CustLedEntry.SetCurrentKey("Posting Date");

           CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');

           CustLedEntry.SetAscending("Posting Date", false);

           IF CustLedEntry.FindFirst() THEN begin

               CustLedEntry1.SetRange("Posting Date", CustLedEntry."Posting Date");

               CustLedEntry1.SetAutoCalcFields("Amount (LCY)");

               if CustLedEntry1.FindSet() then

                   repeat

                       LastDaySaleVar := CustLedEntry1."Amount (LCY)" + LastDaySalevar;

                   until CustLedEntry1.Next() = 0;

           end;

       end;

       var

           LastDaySalevar: Decimal;

           style: Text;

    }

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Prev Day Sale on Role Center

    Pls anyone tell me what is the issue in this code. i want to get last working day/or last posting day sales only

    Page 60113 "LastDaySale"
    {
        PageType = CardPart;
        RefreshOnActivate = true;


        layout
        {
            area(Content)
            {
                cuegroup(cuegroup1)
                {
                    Caption = 'Previous Day Sale';

                    field(LastDaySale; LastDaySalevar)
                    {
                        Caption = 'Prev Day Sale';
                        ApplicationArea = All;
                        StyleExpr = Style;
                        Lookup = true;

                        trigger OnDrillDown()
                        var
                            CustLedEntry: Record "Cust. Ledger Entry";
                            CustLedEntrylist: Page "Customer Ledger Entries";
                        begin
                            // Clear(CustLedEntry);
                            // CustLedEntry.Reset();

                            // //   if (CustLedEntry."Global Dimension 1 Code" = 'SSD') or (CustLedEntry."Global Dimension 1 Code" = 'HID') or (CustLedEntry."Global Dimension 1 Code" = 'IND') then begin
                            // CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');
                            // CustLedEntry.SetRange("Posting Date", CalcDate('-6M', Today));

                            Clear(CustLedEntrylist);
                            CustLedEntry.SetCurrentKey("Posting Date");

                            CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');

                            CustLedEntry.SetAscending("Posting Date", false);
                            IF CustLedEntry.FindFirst() THEN BEGIN

                                CustLedEntrylist.SETTABLEVIEW(CustLedEntry);

                                CustLedEntrylist.Run();
                                CustLedEntrylist.Close();

                            end;


                        end;
                    }
                }

            }
        }

        trigger OnAfterGetCurrRecord()
        var
            CustLedEntry: Record "Cust. Ledger Entry";
            CustLedEntrylist: Page "Customer Ledger Entries";
        begin
            // CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');
            // CustLedEntry.SetAscending("Posting Date", false);

            Clear(CustLedEntrylist);
            CustLedEntry.SetCurrentKey("Posting Date");

            CustLedEntry.SetFilter("Global Dimension 1 Code", '%1|%2|%3', 'SSD', 'IND', 'HID');

            CustLedEntry.SetAscending("Posting Date", false);

            IF CustLedEntry.FindFirst() THEN BEGIN

                CustLedEntrylist.SETTABLEVIEW(CustLedEntry);

                CustLedEntrylist.RunModal();

            end;

        end;

        var

            LastDaySalevar: Decimal;
            style: Text;
    }
  • Suggested answer
    JAngle Profile Picture
    JAngle 33,155 on at
    RE: Prev Day Sale on Role Center

    Codeunit 1311 "Activities Mgt." is used in conjunction to the table and page. The codeunit runs a function called RefreshActivitiesCueData which then iterates through various fields to give them values for the user. the one to copy is probably CalcSalesThisMonthAmount as that eventually results in a filter on the customer ledger entry table. This approach is long winded so you might want to try an easier method. This blog discusses some: businesscentralgeek.com/2-ways-to-create-cues

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Prev Day Sale on Role Center

    tableextension 60100 "Last Day Sale RC" extends "Activities Cue"
    {
    
        fields
        {
            field(55003; LastDaySale; Decimal)
            {
    
                AutoFormatExpression = GetAmountFormats();
                AutoFormatType = 11;
                Caption = 'Previous Day Sale';
                DecimalPlaces = 0 : 0;
    
            }
    
        }
        procedure GetAmountFormats(): Text
        var
            GeneralLedgerSetup: Record "General Ledger Setup";
            UserPersonalization: Record "User Personalization";
            CurrencySymbol: Text[10];
        begin
            GeneralLedgerSetup.Get();
            CurrencySymbol := GeneralLedgerSetup.GetCurrencySymbol;
    
            if UserPersonalization.Get(UserSecurityId) and (CurrencySymbol <> '') then
                case UserPersonalization."Locale ID" of
                    1030, // da-DK
                  1053, // sv-Se
                  1044: // no-no
                        exit(''   CurrencySymbol);
                    2057, // en-gb
                  1033, // en-us
                  4108, // fr-ch
                  1031, // de-de
                  2055, // de-ch
                  1040, // it-it
                  2064, // it-ch
                  1043, // nl-nl
                  2067, // nl-be
                  2060, // fr-be
                  3079, // de-at
                  1035, // fi
                  1034: // es-es
                        exit(CurrencySymbol   '');
                end;
    
            exit(GetDefaultAmountFormat);
        end;
    
        local procedure GetDefaultAmountFormat(): Text
        begin
            exit('');
        end;
    }
    
    
    

  • JAngle Profile Picture
    JAngle 33,155 on at
    RE: Prev Day Sale on Role Center

    What is the code for the new field on the table? The page extension doesn’t reveal much.

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Prev Day Sale on Role Center

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans