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 :
Microsoft Dynamics AX (Archived)

how To create a item using x++

(0) ShareShare
ReportReport
Posted on by

Hi Friends,

I want to know how to create a new item using x++ in Ax 2012.

Thanks&Regards

Ashwini.E

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,896 Super User 2025 Season 2 on at

    Hi Ashwini,

    What is the background of your question? In what process is it required? Is it for integrating with other systems which provides product information? With more information you will get a better answer compared to only "inventTable.insert()".

  • Community Member Profile Picture
    on at

    Hi Andre

    I want to create a new item using x++ coding

    public static void CreateNewItem((ItemId _itemId,ItemName _itemName,BOMUnitId BOM, ItemGroupId _itemGroup, InventDimGroupId _dimGroup,InventModelGroupId _modelGroup,Price price1)

    {

      InventTable         inventTable;

       InventTableModule   inventTableModule;

       InventItemLocation  inventItemLocation;

       ;

       ttsbegin;

       // Master record in InventTable

       select forupdate inventTable;

       inventTable.initValue();

       // If InventTable has other mandatory fields in addition to

       // ItemGroupId and ItemId, they should be defined here

       inventTable.ItemGroupId = _itemGroup;

       inventTable.ModelGroupId=_modelGroup;

       inventTable.DimGroupId=_dimGroup;

       inventTable.BOMUnitId= UOM;

       inventTable.ItemId = _itemId;

       inventTable.ItemName = _itemName;

       inventTable.ItemType = ItemType::Item;

       inventTable.ItemIdCompany="";

       // You can put default DimGroupId, ModelGroupId, etc. here

       inventTable.insert();

       // InventItemLocation for default dimension

       select forupdate inventItemLocation;

       inventItemLocation.initValue();

       inventItemLocation.ItemId = _itemId;

       inventItemLocation.InventDimId = InventDim::inventDimIdBlank();

       inventItemLocation.insert();

       // Three records in InventTableModule (for Cost, Purchase and Sales)

       //  you can also set the price, unit and other values here

       select forupdate inventTableModule;

       // Cost

       inventTableModule.initValue();

       inventTableModule.ItemId = _itemId;

       inventTableModule.Price = price1;

       inventTableModule.UnitId=UOM;

       inventTableModule.ModuleType = ModuleInventPurchSales::Invent;

       inventTableModule.insert();

       // Purchase order

       inventTableModule.initValue();

       inventTableModule.ItemId = _itemId;

       inventTableModule.Price = price1;

       inventTableModule.UnitId=UOM;

       inventTableModule.ModuleType = ModuleInventPurchSales::Purch;

       inventTableModule.insert();

       // Sales order

       inventTableModule.initValue();

       inventTableModule.ItemId = _itemId;

       inventTableModule.Price = price1;

       inventTableModule.UnitId=UOM;

       inventTableModule.OverDeliveryPct=0;

       inventTableModule.UnderDeliveryPct=100;

       inventTableModule.ModuleType = ModuleInventPurchSales::Sales;

       inventTableModule.insert();

       ttscommit;

     }

    i have used this coding i am get some error please give a solution for create a new item in ax 2012 using x++ .

    Thanks&Regards

    Ashwini

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    That depends on the country of your legal entity, the setup of product licenses (which modules are used) and license configuration keys, finally the parametrisation of your system. The business process flow for creating item and the mandatory fields to be filled could be different due to this.

    We will not be able to give definitive answer due to every system deployment being unique as per the above combination.

    One of the first traits a junior developer should have is know how to use a search engine and rely on documentation and blogs. You could find high level concepts of how to create a product master and release that to a company if you would use a search engine in 2 minutes, which takes less than typing your question in the forum.

    Let me google that for you:

    [View:http://lmgtfy.com/?q=ax+2012+create+item+x%2B%2B:750:50]

  • André Arnaud de Calavon Profile Picture
    300,896 Super User 2025 Season 2 on at

    Hi Ashwini,

    Can you also share what error message(s) you get?

  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi Ashwini,

    Please refer the below link:

    http://fandyax.blogspot.in/2013/04/how-to-using-x-create-item-in.html

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans