Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans