I’ve created a dataport to import the counted quantities from a physical inventory into the Phys. Inventory Journal. I only want to import the “Phys. Inventory” quantity. Everything works and the quantity does go into the field but it doesn’t update the “Quantity” field as is would had I keyed in the number rather than imported it. I have the following code in the “On After Import Record” area: VALIDATE(“Item Journal Line”.“Phys. Inventory”); This does not work. What am I missing?
Hi, You’re validating the boolean field not the Qty. field, try VALIDATE(“Item Journal Line”.“Qty. (Phys. Inventory)” You can accomplish this without code by setting the CallFieldValidate property to Yes.
Thank you, I was using the wrong field. Now that I’ve changed it I am still having the same problem. I’ve added MODIFY to the end and that does update the “Quantity” field properly but, unfortunatly, it deletes most of the other information on the line. I know this is simple, but I’m just not getting it.[Duh!]
The lines in the import file must be in the exact same sequence as the Journal, i.e. have the same primary key “Journal Template Name”,“Journal Batch Name”,“Line No.”, otherwise you’ll mess things up. If this is not the case you’ll have to make a search in the Journal for each Item before updating it (something along these lines) Item Journal Line - OnAfterImportRecord() ItemJournalLine.RESET; ItemJournalLine.SETRANGE(“Journal Template Name”, “Journal Template Name”); ItemJournalLine.SETRANGE(“Journal Batch Name”, “Journal Batch Name”); ItemJournalLine.SETRANGE(“Item No.”, “Item No.”); IF ItemJournalLine.FIND(’-’) THEN BEGIN ItemJournalLine.VALIDATE(“Qty. (Phys. Inventory)”, “Qty. (Phys. Inventory)”); ItemJournalLine.MODIFY; END ELSE CurrDataport.SKIP; where ItemJournalLine is a record variable. Also you’ll have to set the AutoSave property to No. The above is based on the assumption that your file consist of lines with at least the fields “Journal Template Name”,“Journal Batch Name”, “Item No.” and “Qty. (Phys. Inventory)”. Beware: If you’re using locations the code should be modified to deal with this as well.
It works beautifully. Mange tak! I really appreciate your help.