Tuesday, November 17, 2020

Create External Item for Product master in Ax 2012 using X++

 Hi guys, Today we see how to create New external Item for Product master in Ax 2012 using X++.

static void externalProduct(Args _args)

{

    InventTable                 inventTable;

    InventDim                   inventDim;

    InventDimCombination        inventDimCombination;

    custVendExternalItem        custVendExternalItem,custVendExternalItemLoc;

    RefRecId                    _productMasterRecId = 52565460661;

    

        inventTable = InventTable::findByProduct(_productMasterRecId);


        select firstOnly InventDimId, ItemId from inventDimCombination

            where inventDimCombination.ItemId == inventTable.ItemId;


        inventDim = InventDim::find(inventDimCombination.InventDimId);


        select firstOnly custVendExternalItemLoc

            where custVendExternalItemLoc.ItemId == inventTable.ItemId;


        custVendExternalItem.clear();

        custVendExternalItem.initValue();

        custVendExternalItem.ItemId             = inventDimCombination.ItemId;

        custVendExternalItem.ExternalItemId     = inventTable.ItemId;

        custVendExternalItem.ModuleType         = ModuleInventPurchSalesVendCustGroup::CustGroup;

        custVendExternalItem.CustVendRelation   = '01';

        custVendExternalItem.ExternalItemTxt    = inventTable.itemName();

        custVendExternalItem.Description        = inventTable.itemName();

        custVendExternalItem.InventDimId        = inventDim.inventDimId;

        custVendExternalItem.insert();

        info('externalProuct created');

}

Keep Daxing!!

No comments:

Post a Comment