You’ll need to make sure your sales line record has a type of Item.
Then retrieve that item from the database (GET).
Then do a CALCFIELDS on the Inventory field. As said in the reply above it is a flowfield. That means it is not a field stored in the database. It is calculated whenever it is needed. You have to tell the system to calculate it, thus the CALCFIELDS.
You should make a new variable (InventoryVar), then put a textbox in your SalesLine body section and set the SourceExpr of the textbox to be your variable (InventoryVar). Then, in the Sales Line dataitem - OnAfterGetRecord, put the code:
IF (“Sales Line”.“Type.” = 2) AND (“Sales Line”.“No.” <> ‘’) THEN BEGIN
ItemRec.GET(“Sales Line”.“No.”);
ItemRec.CALCFIELDS(Inventory);
InventoryVar := ItemRec.Inventory;
END;
As Matt said before, you should check that your sales line has the type = item (that’s what the first condition is doing, 2 = Item option).
Also, i would make that GET without an IF, since it seems ok to me to throw an error if somehow you have in a sales line an item that
not exists in Item table. If you don’t want to throw an error then you can use the IF and you will obtain a blank textbox if this situation arises.
Also, don’t forget to reinitialise your variable, since it is global.