pageextension 50123 ItemInvFactBoxExt extends "Item Invoicing FactBox"
{
layout
{
addlast(content)
{
field(AvgSalesAmount; AvgSalesAmount)
{
ApplicationArea = All;
Caption = 'Average Sales Amount';
}
}
}
trigger OnAfterGetCurrRecord()
var
ItemLedgerEntry: Record "Item Ledger Entry";
counter: Integer;
sum: Decimal;
begin
ItemLedgerEntry.SetRange("Item No.", Rec."No.");
if ItemLedgerEntry.FindSet() then
repeat
ItemLedgerEntry.CalcFields("Sales Amount (Actual)");
sum := sum + ItemLedgerEntry."Sales Amount (Actual)";
counter := counter + 1;
until ItemLedgerEntry.Next() = 0;
if counter = 0 then
AvgSalesAmount := 0
else begin
AvgSalesAmount := sum / counter;
end;
end;
var
AvgSalesAmount: Decimal;
}
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156