web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
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 234
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.
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    98,455 Super User 2026 Season 1 on at
    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
     
  • Pragya752 Profile Picture
    234 on at
    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;


     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,850 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,045 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans