ArturV, Greatly appreciate your patience going through my code and your kind feedback.
I had revise the code as below:
codeunit 60100 "ReorderBuildSource"
{
trigger OnRun()
begin
end;
PROCEDURE ReorderBuild(VAR ReorderedItem: Record Item);
VAR
Item: Record Item;
BEGIN
IF Item.FINDSET THEN
REPEAT
Item.CALCFIELDS("Safety Stock Quantity");
IF Item."Safety Stock Quantity" - (Item.Inventory + Item."Qty. on Purch. Order") < 0 THEN BEGIN
ReorderedItem := Item;
ReorderedItem.INSERT;
END;
UNTIL Item.NEXT = 0;
END;
}
page 60100 ItemReorderList
{
PageType = list;
SourceTable = Item;
SourceTableTemporary = true;
UsageCategory = Lists;
ApplicationArea = All;
Caption = 'Item Below Safety Level';
layout
{
area(Content)
{
repeater(control)
{
field("No."; "No.")
{ ApplicationArea = All; }
field(Description; Description)
{ ApplicationArea = All; }
field(Inventory; Inventory)
{ ApplicationArea = All; }
field("Qty. on Purch. Order"; "Qty. on Purch. Order")
{ ApplicationArea = All; }
field("Safety Stock Quantity"; "Safety Stock Quantity")
{ ApplicationArea = All; }
field("Suggested Reorder"; "Safety Stock Quantity" - (Inventory + "Qty. on Purch. Order"))
{ ApplicationArea = All; }
}
}
}
trigger OnOpenPage();
var
ReorderBuildSource: Codeunit "ReorderBuildSource";
begin
ReorderBuildSource.ReorderBuild(Rec);
end;
}
If i were to add this line in the procedure
Item.CALCFIELDS("Safety Stock Quantity");
I would encounter message "The Safety Stock Quantity field in the Item table must be a FlowField." when i call this list page at BC.
I tried commenting the statement
// Item.CALCFIELDS("Safety Stock Quantity");
And only have the following statements
IF Item."Safety Stock Quantity" - (Item.Inventory + Item."Qty. on Purch. Order") > 0 THEN BEGIN
ReorderedItem := Item;
ReorderedItem.INSERT;
END;
It managed to get the records to the list page but the filteration is based on Safety Stock Quantity > 0 with the calculation where it minus out the Inventory and Qty on Purchase Order. I had tried changing to = 0 and i can see that it is taking up records where safety stock = 0.
I would again appreciate your patience on reviewing the above and advise me on where i went wrong.
Thanking you inadvance.
May