Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

How to run Trigger Onaftergetrecord once an action is completed on a page

(1) ShareShare
ReportReport
Posted on by 210
I have a page which is of worksheet type. This page have data in matrix format like how it is in standard table /ITEM AVAILABILITY BY LOCATION/. Now if I am populating data in Onaftergetrecord then only,data is getting populated otherwise, its not. Can anyone tell me how to proceed.
 
  • Pragya752 Profile Picture
    Pragya752 210 on at
    How to run Trigger Onaftergetrecord once an action is completed on a page
    Okay, I will explain you. We have a worksheet page where there is a listpart.On listpart, data has to be populated when a dropdown field in header is selected. So on worksheet when dropdown is selected, data in listpart matrix has to change dynamically.When I am doing it through Trigger Onaftergetrecord on listpart it is working fine but when trying to populate data via writing a procedure in worksheet page,it is not working.

    Trigger on after getrecord
     trigger OnAfterGetRecord()
        var
            MATRIX_CurrentColumnOrdinal: Integer;
        begin
            MATRIX_CurrentColumnOrdinal := 0;
            leaseinfo.SetCurrentKey(LeaseCommencementDate);
            leaseinfo.SetAscending(LeaseCommencementDate,true);
            if leaseinfo.FindFirst() then
                repeat
                    MATRIX_CurrentColumnOrdinal := MATRIX_CurrentColumnOrdinal + 1;
                    MATRIX_OnAfterGetRecord(MATRIX_CurrentColumnOrdinal);
                until (MATRIX_CurrentColumnOrdinal = 12);
        end;
     
       
     
        local procedure MATRIX_OnAfterGetRecord(ColumnID: Integer)
        var
            TempItem: Record "ADT-Lease Information" temporary;
            Startdate: Text;
            Enddate: Text;
            NewCaption: Text[80];
            pmmgmt: Codeunit PeriodPageManagement;
     
        begin
            TempItem.Copy(Rec);
            Startdate := Format(Date2DMY(TempItem.LeaseCommencementDate, 3));
            Enddate := Format(Date2DMY(TempItem.LeaseCommencementEndDate, 3));
            NewCaption := Format(DMY2Date(1, 1, Date2DMY(TempItem.LeaseCommencementDate, 3) + ColumnID - 1), 0, '<Year4>');
     
            MATRIX_CaptionSet[ColumnID] := NewCaption;
            if (Startdate <= MATRIX_CaptionSet[ColumnID]) and (MATRIX_CaptionSet[ColumnID] <= Enddate) then
                MATRIX_CellData[ColumnID] := true
            else
                MATRIX_CellData[ColumnID] := false;
     
        end;


    procedure is not working
     
      procedure UpdateData(Period: Enum "Day Filter"; ColumnID: Integer; LeaseInfoRec: Record "ADT-Lease Information")
        var
            TempItem: Record "ADT-Lease Information" temporary;
            Startdate: Date;
            Enddate: Date;
            NewCaption: Text[80];
            CaptionDate: Date;
            Month: Integer;
            Year: Integer;
            StartMonth: Integer;
            EndMonth: Integer;
            StartYear: Integer;
            EndYear: Integer;
        begin
     
            rec.get(LeaseInfoRec.Number);      
            TempItem.Copy(rec);
     
            Startdate := TempItem.LeaseCommencementDate;
            Enddate := TempItem.LeaseCommencementEndDate;
     
            StartMonth := Date2DMY(Startdate, 2);
            EndMonth := Date2DMY(Enddate, 2);
            StartYear := Date2DMY(Startdate, 3);
            EndYear := Date2DMY(Enddate, 3);
     
            case Period of
                Period::Day:
                    begin
                        // Handle Day calculations
                    end;
                Period::Month:
                    begin
                        Month := ColumnID; // Set the month based on the ColumnID
                        Year := 2024; // Set the year to 2024
                        NewCaption := Format(DMY2Date(1, Month, Year), 0, '<Month,2>/<Year4>');
                        CaptionDate := DMY2Date(1, Month, Year);
                    end;
                Period::Year:
                    begin
                        Year := Date2DMY(TempItem.LeaseCommencementDate, 3) + ColumnID - 1;
                        NewCaption := Format(DMY2Date(1, 1, Year), 0, '<Year4>');
                        CaptionDate := DMY2Date(1, 1, Year);
                    end;
            end;
     
            MATRIX_CaptionSet[ColumnID] := NewCaption;
     
            if (Startdate <= CaptionDate) and (CaptionDate <= Enddate) then
                MATRIX_CellData[ColumnID] := true
            else
                MATRIX_CellData[ColumnID] := false;
     
            Rec.Modify();
       
            CurrPage.Update();
        end;
     
        local procedure FormatStr(): Text
        begin
            exit(RoundingFactorFormatString);
        end;


     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 76,147 Super User 2024 Season 2 on at
    How to run Trigger Onaftergetrecord once an action is completed on a page
    I'm sorry I may not fully understand what you mean.
    I think you can add an action, such as the page below, to manually refresh the data.
     
    Hope this can give you some hints.
    Thanks.
    ZHU
     

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,883 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans