D365 Business Central : The Mysterious Case of Bin Content Quantity
I was working on getting inventory availability using Bin Contents and for some reason, I could never get the correct quantity for each Bin.
Quantity field in Bin Content is a FlowField which means the field is not a physical field. It is calculated when needed from Warehouse Entry.
Quantity is related to the Unit of Measure. Quantity (Base) is related to the Base Unit of Measure. In the above example:
1 BOX = 12 EA, so Quantity : 1 BOX = Quantity (Base) : 12 EA.
Let’s try creating simple action to show the Quantity on the Bin Contents page.
addlast(Processing)
{
action(MessageQty)
{
Caption = 'Message Quantity';
ApplicationArea = All;
trigger OnAction()
begin
Rec.CalcFields(Quantity);
Message('Quantity : %1', Rec.Quantity);
end;
}
}
If I run the above code, the message actually shows 12 which is Quantity (Base), not Quantity. Why ?
Quantity field is a FlowField, so I decided to take a look at the table Warehouse Entry directly. Surprisingly, the Quantity and Quantity (Base) have the exact same value, even though the record is not in Base Unit of Measure.
How come the page show the correct quantity though ? It turns out that on the Bin Contents page, BC actually recalculates the Quantity from Quantity (Base). The table field Quantity itself is not being used on the page.
Why is it designed this way ? No idea. Just be aware when you are using Bin Content Quantity.
1 Response
[…] The Mysterious Case of Bin Content Quantity […]