web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Inventory dimension Site is mandatory and must consequently be specified while creating production order in D365f0

(0) ShareShare
ReportReport
Posted on by 92

Hi,

I'm trying to create production order through code but it giving an error of "Inventory dimension Site is mandatory and must consequently be specified." even I've set the site and location.

Below is the code

ProdTable prodtable;
InventTable inventTable;
InventDim inventDim,inventDimlocal;
InventItemOrderSetupType setupType = InventItemOrderSetupType::Invent;
;

inventTable = inventTable::find(_selectedLines.ItemNumber);

prodtable.initValue();
prodtable.initFromInventTable(inventTable);

prodtable.ItemId = inventTable.ItemId;
prodtable.DlvDate = _selectedLines.RequestDate;
prodtable.QtySched = _selectedLines.Quantity;
prodtable.RemainInventPhysical = _selectedLines.Quantity;

inventDim.initValue();

inventDim.InventSiteId = '1';

// Default Location

inventDim.InventLocationId = '11';

inventDim.ConfigId = inventTable.StandardConfigId;

inventDimlocal = InventDim::findOrCreate(inventDim);

prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDimlocal).BOMId;

prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
prodtable.BOMDate,
prodtable.QtySched,
inventDimlocal).RouteId;

prodtable.initBOMVersion();
prodtable.initRouteVersion();
ttsbegin;
prodtable.insert();
ttscommit;

Anyone facing this issue or resolve this. let me know. Remember inserting and inserted method functionality do nothing.
Regards,
Zohan
I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    A good general approach to such errors is to look at the production orders that are created via D365 UI, using table browser or SQL Server Management Studio. This way you will see what good data looks like.

    Then try to write code that creates similar data.

    Seems that you don't set ProdTable.InventDimId in your code. Perhaps that causes the error.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans