I am trying to populate list with filtered records in temporary table. Records in temp table are stored and counted properly. But when page is open all records from original table are displayed.
procedure DrillDown_Cust_Retail_Open()
var
CustomerLedgerEntry: Record "Cust. Ledger Entry";
TempCustomerLedgerEntries: Record "Cust. Ledger Entry" temporary;
CustomerLedgerPage: Page "Customer Ledger Entries";
begin
// Reset records and apply initial filter
CustomerLedgerEntry.Reset();
CustomerLedgerEntry.SetRange("Open", true);
// Fetch and insert filtered records into the temporary table
if CustomerLedgerEntry.FindSet() then begin
repeat
TempCustomerLedgerEntries := CustomerLedgerEntry;
TempCustomerLedgerEntries.Insert();
until CustomerLedgerEntry.Next() = 0;
end;
// Confirm filtered records
Message('Filtered records count: %1', TempCustomerLedgerEntries.Count());
// Verify that the temporary table contains the correct records before opening the page
if TempCustomerLedgerEntries.FindSet() then begin
end else begin
Message('No records found');
end;
// Set the table view to the temporary records
CustomerLedgerPage.SetTableView(TempCustomerLedgerEntries);
Message('Opening page with filtered records.');
CustomerLedgerPage.Run();
end;
SetTableView
only copies the current View
you have set on the record meaning filters, sorting etc. corresponding to calling the GetView
and SetView
procedures on a record variable.
It is not a reference to the actual temporary instance of the table.
You could try running the page on the record instead:
Page.Run(Page::"Customer Ledger Entries", TempCustomerLedgerEntries);