tableextension 50103 SalesLinesTable extends "Sales Line"
{
fields
{
// Add changes to table fields here
field(50101; "Sum of Quantity"; Decimal)
{
AccessByPermission = TableData Location = R;
BlankZero = true;
CalcFormula = Sum ("Sales Line".Quantity
WHERE("Document No." = FIELD("Document No.")));
DecimalPlaces = 0 : 5;
Editable = false;
FieldClass = FlowField;
trigger OnValidate()
begin
ILE.Reset();
ILE.Setcurrentkey("No.", "Location Code");
ILE.Setrange("No.", "No.");
ILE.Setrange("Location Code", "Location Code");
IF ILE.FINDFIRST THEN BEGIN
ILE.Calcsums(Quantity);
decQty := ILE.Quantity;
END;
end;
}
}
trigger OnInsert()
begin
ILE.Reset();
ILE.Setcurrentkey("No.", "Location Code");
ILE.Setrange("No.", "No.");
ILE.Setrange("Location Code", "Location Code");
IF ILE.FINDFIRST THEN BEGIN
ILE.Calcsums(Quantity);
decQty := ILE.Quantity;
END;
end;
trigger OnDelete()
begin
ILE.Reset();
ILE.Setcurrentkey("No.", "Location Code");
ILE.Setrange("No.", "No.");
ILE.Setrange("Location Code", "Location Code");
IF ILE.FINDFIRST THEN BEGIN
ILE.Calcsums(Quantity);
decQty := ILE.Quantity;
END;
end;
trigger OnModify()
begin
ILE.Reset();
ILE.Setcurrentkey("No.", "Location Code");
ILE.Setrange("No.", "No.");
ILE.Setrange("Location Code", "Location Code");
IF ILE.FINDFIRST THEN BEGIN
ILE.Calcsums(Quantity);
decQty := ILE.Quantity;
END;
end;
var
ILE: Record "Sales Line";
decqty: Integer;
}
However, When I open page it's working fine. But, when I am inserting record deleting then it's not changing value at the same time in a field. Please help me solve this.
Thank You