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)

Create Product in Ax 2012 using X++ Code

(0) ShareShare
ReportReport
Posted on by 288

Hi,

How to create a product and release that product based on Company using X++ or manual ax 2012 ??

thanks, advance.. :)

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    vivo88 Profile Picture
    1,066 on at

    Please refer the below link to create Products in AX 2012 using X++ code:

    pawansaxblog.blogspot.in/.../how-to-create-product-in-ax2012-using-x.html

  • Suggested answer
    Santosh Yadav Profile Picture
    420 on at

    use below job, it takes data from excel and create/release product in your current LE - tweak it as needed.

    static void createAndReleaseProduct(Args _args)

    {

       EcoResProductService                    ecoResProdService;

       EcoResEcoResProduct                     ecoResProd;

       EcoResEcoResProduct_Product             product;

       EcoResEcoResProduct_Translation         translation;

       EcoResEcoResProduct_Identifier          identifier;

       EcoResEcoResProduct_ProductDimGroup     productDimGroup;

       EcoResEcoResProduct_TrackingDimGroup    trackingDimGroup;

       EcoResEcoResProduct_StorageDimGroup     storageDimGroup;

       InventModelGroupItem                    inventModelGroupItem;

       InventItemGroupItem                     inventItemGroupItem;

       InventTable                             inventTable;

       DimensionAttributeValueSetStorage       storage;

       container                               dimAttributeList;

       container                               dimValueList;

       int                                     i;

       DimensionDefault                        defaultDimension;

       SysExcelApplication                     application;

       SysExcelWorkbooks                       workbooks;

       SysExcelWorksheets                      worksheets;

       SysExcelWorksheet                       worksheet;

       SysExcelCells                           cells;

       COMVariantType                          type;

       int                                     row;

       str                                     productName;

       str                                     storageDim;

       str                                     trackingDim;

       str                                     itemModelGroup;

       str                                     itemGroupItem;

       str                                     prodDimGroup;

       Name                                    searchName;

       application = SysExcelApplication::construct();

       workbooks   = application.workbooks();

       //specify the file path that you want to read

       workbooks.open(@'C:\item.xlsx');

       worksheets  = workbooks.item(1).worksheets();

       worksheet   = workbooks.item(1).worksheets().itemFromNum(1);

       cells       = worksheet.cells();

       do

       {

           row ++;

           productName     = cells.item(row, 1).value().bStr();

           searchName      = cells.item(row, 2).value().bStr();

           storageDim      = cells.item(row, 3).value().bStr();

           trackingDim     = cells.item(row, 4).value().bStr();

           itemModelGroup  = cells.item(row, 5).value().bStr();

           itemGroupItem   = cells.item(row, 6).value().bStr();

           type            = cells.item(row+1, 1).value().variantType();

           //Initialize the service object

           ecoResProdService   = EcoResProductService::construct();

           ecoResProd          = new EcoResEcoResProduct();

           product             = new EcoResEcoResProduct_Product_Distinct();

           //Newly created and initialize prodMaster

           product.parmDisplayProductNumber(productName);

           product.parmProductType(EcoResProductType::Item);

           product.parmSearchName(searchName);

           //Create a new translation object:

           translation = product.createTranslation().addNew();

           translation.parmDescription("product");

           translation.parmLanguageId("en-us");

           translation.parmName("Product data");

           identifier = product.createIdentifier().addNew();

           identifier.parmProductNumber(productName);

           // Storage dimension

           storageDimGroup = product.createStorageDimGroup().addNew();

           storageDimGroup.parmProduct(productName);

           storageDimGroup.parmStorageDimensionGroup(storageDim);

           // tracking dimension

           trackingDimGroup = product.createTrackingDimGroup().addNew();

           trackingDimGroup.parmProduct(productName);

           trackingDimGroup.parmTrackingDimensionGroup(trackingDim);

           ecoResProd.createProduct().add(product);

           ecoResProdService.create(ecoResProd);

           // Release to current legal entity

           EcoResProductReleaseManager::releaseProductWithLegalEntityData(EcoResProduct::findByProductNumber(productName).RecId,

                                                                          CompanyInfo::findDataArea(curext()).RecId,

                                                                          productName,

                                                                          searchName);

           inventTable = InventTable::find(productName);

           inventModelGroupItem.clear();

           // insert entry to inventModelGroupItem

           inventModelGroupItem.ModelGroupId           = itemModelGroup;

           inventModelGroupItem.ItemDataAreaId         = inventTable.dataAreaId;

           inventModelGroupItem.ModelGroupDataAreaId   = inventTable.dataAreaId;

           inventModelGroupItem.ItemId                 = inventTable.ItemId;

           inventModelGroupItem.insert();

           inventItemGroupItem.clear();

           // insert entry to inventItemGroupItem

           inventItemGroupItem.ItemDataAreaId          = inventTable.dataAreaId;

           inventItemGroupItem.ItemId                  = inventTable.ItemId;

           inventItemGroupItem.ItemGroupId             = itemGroupItem;

           inventItemGroupItem.ItemGroupDataAreaId     = inventTable.dataAreaId;

           inventItemGroupItem.insert();

           info(strfmt('Product %1 imported and released to legal entity %2.', productName, CompanyInfo::findDataArea(curext()).Name));

       }

       while (type != COMVariantType::VT_EMPTY);

       {

           application.quit();

       }

    }

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