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 :
Supply chain | Supply Chain Management, Commerce
Unanswered

Create Production Order through X++

(0) ShareShare
ReportReport
Posted on by 35

Hi All,

I am trying to create a Production order in D365 F&O with the following code but a record not getting inserted in ProdTable.
Can someone let me know a solution.

static void _CreateProductionOrder(Args _args)
{
    ProdQty         qty     = 100;
    ItemId          item    = 'ECJ';
 
    ProdTable       prodtable;
    InventTable     inventTable;
    InventDim       inventDim;
    ;
 
    
    inventTable = inventTable::find(item);
 
    
    prodtable.initValue();
    prodtable.initFromInventTable(inventTable);
 
    prodtable.ItemId                = inventTable.ItemId;
    prodtable.DlvDate               = today();
    prodtable.QtySched              = qty;
    prodtable.RemainInventPhysical  = qty;
 
   
    inventDim.initValue();
 
    
    prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
                                             prodtable.BOMDate,
                                             prodtable.QtySched,
                                             inventDim).BOMId;
 
    prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
                                                 prodtable.BOMDate,
                                                 prodtable.QtySched,
                                                 inventDim).RouteId;
 
   
    prodtable.initBOMVersion();
    prodtable.initRouteVersion();
 
    prodtable.type().insert();// Record not getting inserted 
 
   
    info(prodtable.ProdId);
}
I have the same question (0)
  • Blue Wang Profile Picture
    on at

    HI Samir,

    prodtable.type().insert(); running  in AX2012.

    Please  try to use prodtable.type().inserted(); or Inserting().

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Hi Samir, I moved your question from AX 2012 forum. Now I wonder how it is relayed to things like "Windows 8 and Mobile Apps", "Connector for CRM", "Management Reporter" or "Enterprise Portal", which are all categories you've selected for your thread. Please pick them more carefully next time.

  • Samir Sharma Profile Picture
    35 on at

    Hi Blue,

    Thanks for replay,

    Yes, it works fine in Ax2012, But in D365 F&O it's not. also, I tried inserted(); or Inserting(). but hard luck.

    Regards

  • Samir Sharma Profile Picture
    35 on at

    Thanks Martin,

    Great minds are everywhere, Can you help me as it works fine in Ax2012 but not in D365 F&O

    Thanks

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    ProdTableType.insert() is deprecated. If you want to insert records, use ProdTable.insert(). If you want to add extra logic on insert, consider methodsProdTableType.inserting() and ProdTableType.inserted().

  • Samir Sharma Profile Picture
    35 on at

    Hi Martin,

    I alredy tried all this but still no output.

    Can you give me working example with above code.

    Thanks

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    You can easily find examples by right-clicking ProdTable.insert() and choosing Find Refences, but there is nothing special about calling insert() method. You should rather debug your solution.

    Review how you test that data was inserted - maybe you're looking through a form where you record is filtered out because of missing references. Look into the table directly.

    Make sure that your code gets called at all and that it doesn't fail. Note that if an exception occurs even after insert(), but in the same database transaction, the insert will be rolled back and therefore nothing will be written to database.

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 301 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Siv Sagar Profile Picture

Siv Sagar 105 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans