Skip to main content

Notifications

Microsoft Dynamics NAV forum
Suggested answer

Run "Calculate Inventory" Report 790 from a CodeUnit to populate the Phys. Inventory Journals

Posted on by 5

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?

  • Suggested answer
    RE: Run "Calculate Inventory" Report 790 from a CodeUnit to populate the Phys. Inventory Journals

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans