Hi I am working on Custom page and table using al code. On page WarRegFormItemLinkSubLinePage, I am getting price using flowfield from WarrantyProductSubline page, which is working fine. However, I am not getting sum of lines in TotalPrice field. It's giving me only one row price, not sum up the price of all lines, when I do trigger on item no field. I am running trigger using procedure UpdatePrice(). Please help me to find where I am doing mistake. Thank You
table 50108 WarRegFormItemLinkSubLine
{
Caption = 'WarRegFormItemLinkSubLine';
/* DataCaptionFields = "No.", PName; */
fields
{
field(50100; "No."; Integer)
{
Caption = 'No.';
}
field(50101; "No. Series"; Code[20])
{
Caption = 'No. Series';
Editable = false;
TableRelation = "No. Series";
}
field(50102; "WarrantyRegNo"; code[20])
{
Caption = 'WarrantyRegNo.';
TableRelation = WarrantyReg."No.";
}
field(50103; "WarrantyFormNo"; code[20])
{
TableRelation = WarrantyReg.WarrantyFormNo;
}
field(50104; "WarrantyForm"; Text[900])
{
FieldClass = FlowField;
CalcFormula = lookup ("Warranty Forms".Name where("No." = field(WarrantyFormNo)));
}
field(50105; "ItemNo."; Text[900])
{
Caption = 'Item No.';
TableRelation = WarrantyProductSubLine."ItemNo." where("WFNo." = field(WarrantyFormNo));
}
field(50106; "ItemDesc."; Text[900])
{
Caption = 'Item Desc.';
FieldClass = FlowField;
CalcFormula = lookup (Item.Description where("No." = field("ItemNo.")));
}
field(50107; "Price"; Decimal)
{
Caption = 'Price';
FieldClass = FlowField;
CalcFormula = Sum (WarrantyProductSubLine.Price
WHERE("WFNo." = FIELD(WarrantyFormNo), "ItemNo." = FIELD("ItemNo.")));
}
field(50108; "TotalPrice"; Decimal)
{
Caption = 'Total Price';
}
}
keys
{
key(PK; "WarrantyRegNo", "No.", WarrantyFormNo, GenProGrup, TaxProGrup)
{
Clustered = true;
}
}
var
myInt: Integer;
}
page 50112 WarRegFormItemLinkSubLinePage
{
AutoSplitKey = false;
Caption = 'Lines';
DelayedInsert = true;
LinksAllowed = false;
MultipleNewLines = true;
PageType = ListPart;
SourceTable = WarRegFormItemLinkSubLine;
layout
{
area(Content)
{
repeater(Lines)
{
ShowCaption = false;
field("No."; "No.")
{
ApplicationArea = All;
Visible = true;
}
field(WarrantyRegNo; WarrantyRegNo)
{
ApplicationArea = All;
Visible = false;
Editable = false;
}
field(WarrantyFormNo; WarrantyFormNo)
{
ApplicationArea = All;
Caption = 'Warranty Form';
ToolTip = 'Specifies the WarrantyForm of the WarrantyForm.';
Visible = false;
Editable = true;
}
field(WarrantyForm; WarrantyForm)
{
ApplicationArea = All;
Caption = 'Warranty Form Name';
ToolTip = 'Specifies the WarrantyForm of the WarrantyForm.';
Visible = false;
Editable = false;
}
field("ItemNo."; "ItemNo.")
{
ApplicationArea = All;
Caption = 'Item No.';
Visible = true;
Editable = true;
trigger OnValidate()
var
begin
UpdatePrice();
CurrPage.Update();
end;
}
field("ItemDesc."; "ItemDesc.")
{
ApplicationArea = All;
Caption = 'Item Description';
Visible = true;
Editable = false;
}
field("Price"; Price)
{
ApplicationArea = All;
Caption = 'Price';
Visible = true;
Editable = true;
}
}
group("")
{
grid(MyGrid)
{
field("TotalPrice"; TotalRate2)
{
ApplicationArea = All;
Caption = 'Total Price';
trigger OnValidate()
begin
Error('You cannot edit this field.');
end;
}
}
}
}
}
actions
{
area(Processing)
{
action(ActionName)
{
ApplicationArea = All;
trigger OnAction()
begin
end;
}
}
}
trigger OnNewRecord(BelowxRec: Boolean)
var
WRFILSTable: Record WarRegFormItemLinkSubLine;
begin
WRFILSTable.RESET;
WRFILSTable.SETCURRENTKEY("No.");
IF WRFILSTable.FINDLAST THEN Begin
/* MESSAGE('%1', WFTable."No."); */
"No." := WRFILSTable."No." + 10;
End;
end;
procedure UpdatePrice()
var
WPS: Record WarrantyProductSubLine;
WFIS: Record WarRegFormItemLinkSubLine;
begin
TotalRate1 := 0.0;
WPS.SetRange(WPS."WFNo.", WarrantyFormNo);
WPS.SetRange(WPS."ItemNo.", "ItemNo.");
IF WPS.FIND('-') THEN
REPEAT
TotalRate1 += WPS.Price;
MESSAGE('Amount 1: %1', TotalRate1);
UNTIL WPS.NEXT = 0;
TotalRate2 := TotalRate1;
MESSAGE('t1: %1', TotalRate1);
end;
var
TotalRate1: Decimal;
TotalRate2: Decimal;
TotalQty1: Integer;
TotalQty2: Integer;
Desc: Text[900];
myInt: Integer;
}