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;