pageextension 60008 "Assembly Orders PL" extends "Assembly Orders"//902 { trigger OnOpenPage() var AssemblyOrders: Page "Assembly Orders"; OriginalHeader: Record "Assembly Header"; AssemblyHeaderTemp: Record "Assembly Header" temporary; begin if not RunOnce then begin AssemblyHeaderTemp.Reset(); AssemblyHeaderTemp.DeleteAll(); OriginalHeader.SetRange("Document Type", Rec."Document Type"::Order); if OriginalHeader.FindSet() then repeat // Check if the No. Series have extra security if LMEnsamblado.ImplicaSeguridad(OriginalHeader."No. Series") then begin // If the No. Series has extra security, we check if the current user has rights if LMEnsamblado.TienePermisosLM(OriginalHeader."Item No.") then begin AssemblyHeaderTemp.Init(); AssemblyHeaderTemp.TransferFields(OriginalHeader); AssemblyHeaderTemp.CalcFields(Comment); AssemblyHeaderTemp.CalcFields("Reserved Quantity"); AssemblyHeaderTemp.CalcFields("Reserved Qty. (Base)"); AssemblyHeaderTemp.CalcFields("Assemble to Order"); AssemblyHeaderTemp.CalcFields("Rolled-up Assembly Cost"); AssemblyHeaderTemp.Insert(); end; end; until OriginalHeader.Next() = 0; CurrPage.Close(); AssemblyOrders.SetRecord(AssemblyHeaderTemp); AssemblyOrders.SetTableView(AssemblyHeaderTemp); AssemblyOrders.SetRunOnce(); AssemblyOrders.Run(); CurrPage.Update(); end; end; procedure SetRunOnce() begin RunOnce := true end; var LMEnsamblado: Codeunit "LM Ensamblado"; RunOnce: Boolean; }
Answers
You would need to call the page using in order to run it on the temporary table. You can then replace by
Another, and in my opinion better approach was to filter the page, rather that to populate a temporary one.
You could use an approach similar to the one Page 31 Item List uses for Item Attribute filtering, or even drop the temp table and filter on the fly. In essence you need to implement OnFindRecord and OnNextRecord for the page in such a way that it only finds or steps to records you want to show.
Have a look at Filtering data on form using OnFindRecord and OnNextRecord to see how this can be done. Your condition on when to insert a record into the temp table above would go to the function ShowThisRecord there.