On the Phys. Inventory Report I can click the button "Calculate Inventory" which runs a report "Calculate Inventory" Report 790 and populates the Journal page with the values.
I need to be able to run this report from a codeunit so that we can then fetch the values from a webservice call
So far what I has is this:
ItemJournalLine."Document No." := '1'; ItemJournalLine."Posting Date" := 122021D; ItemJournalLine.SETRANGE("Journal Batch Name", 'DEFAULT'); ItemJournalLine.SETRANGE("Journal Template Name", 'PHYS. INVE'); Item.SETFILTER("Location Filter", '001'); Item.SETFILTER("Item Category Code", 'GOODS'); Item.SETFILTER(Blocked, 'No'); CalcQtyOnHand.InitializeRequest(122021D, '1', FALSE, FALSE); CalcQtyOnHand.SetItemJnlLine(ItemJournalLine); CalcQtyOnHand.USEREQUESTPAGE(FALSE); //TODO: FALSE CalcQtyOnHand.SetHideValidationDialog(TRUE); CalcQtyOnHand.SETTABLEVIEW(Item); CalcQtyOnHand.RUNMODAL;
However when I run the code unit I get this error. (and of course the Phys. Inventory Journals is not populated with anything)
The Item Journal Template does not exist. Identification fields and values: Name=''
What do I need to do to select the Phys. Inventory Journals Page as the journal to populate?