Cannot create a record - The record already exists

Hi anyone help me below code i am try insert data Cannot create a record in Items (InventTable). Item number: xxxxx. The record already exists. [Moved from thread title by moderator.]

InventTable inventTable;
EcoResProductTranslation ecoResProductTranslation;

inventTable = InventTable::find(_products.ItmeId(), true);
if (!inventTable.RecId)
{
    inventTable.ItemId = _products.ItmeId();
    inventTable.NameAlias = _products.Name();
    // ecoResProductTranslation.Name = _products.Name();
    inventTable.insert();
}

Make sure

  1. Maintain descriptive subject for the thread
  2. Mention product versiion
  3. Describe the requirement instead of saying not working
    When you are creating a product X++, need to consider standard schema. Otherwise it would effect the data integrity.
    I believe this thread about AX 2012,this may help you.
    axhelper.blogspot.ae/…/product-creation-by-using-x-and-services.html
    daxtechies.blogspot.ae/…/ax2012-r2-creating-product-or-product.html

Thank you Krishna

If you got a solution, don’t forget to mark a reply as verified