On the "Purchase Invoices" page, I want to create a "Totals" section, where the "Amount" and "Amount including VAT" fields of all records are added. To achieve this, I am using the following code:
trigger OnAfterGetCurrRecord()
var
PurchaseHeader: Record "Purchase Header";
begin
PurchaseHeader.CopyFilters(Rec);
PurchaseHeader.CalcSums(Amount, "Amount Including VAT");
TotalAmount := PurchaseHeader.Amount;
TotalAmountIncludingVAT := PurchaseHeader."Amount Including VAT";
end;
But it doesn't work, variables always appear in "0". Use this same code in a page created by myself and there if it worked, do I have to change something as it is a default page or am I making a mistake? Some alternative?