I’m trying to create product/master product in Dynamics AX using AIF inbound port, the AIF services consume by C#.NET.
From AX 2012 R2, Item is replaced with Product. Item master was in Inventory Management Module, now there is a separate module for item/product creation Product information Management.
Some definitions you should know
There are two types of Products in 2012 they are:
Product: Product information management/Common/Products/Products
Product Master: Product information management/Common/Products/Products master
Variants: To create a product variant, you must define at least one product dimension for a product master. You can also rename dimensions.
To create product variants, you must complete the following tasks:
Set up dimensions, such as size, color, and style.
Set up variant groups.
Assign variant groups to a retail hierarchy.
Create a product master and variants.
Product dimensions
Product dimensions are characteristics that serve to identify a product variant. You can use combinations of product dimensions to define product variants. You must define at least one product dimension for a product master to create a product variant.
Process:
Normally in AX, we create items master follow process:
Assigning Item Model Group & Item Groups to a Product Master
How to do:
Ax provides us standard services for this purpose, so we don’t need to create any custom services for this. I will use 4 services for this purpose, descriptions below
Service
Purpose
EcoResProductService
Create products (all types). The service can also be used to retrieve data that has already been created (Create Product details in The EcoRes tables).
EcoResProductMasterDimValueService
Specify values of product dimensions for a product master. These values become available for the creation of product variants. The service can also be used to retrieve data that has already been created.
ItemService
Release distinct products and product masters. The service can also be used to retrieve data that has already been created.
InventDimCombinationService
Release product variants. The service can also be used to retrieve data that has already been created.
1. Create 4 AIF inbound services against Services operation above and active it
2. After services creation, open visual studio then creates new Console project and add service References for that, you will get somethings like pic below:
staticvoidcreateMasterDimensions(){EcoResProductMasterRef.AxdEntity_EcoResSizeecoResSizeL=newEcoResProductMasterRef.AxdEntity_EcoResSize(){Name="L"};EcoResProductMasterRef.AxdEntity_EcoResSizeecoResSizeM=newEcoResProductMasterRef.AxdEntity_EcoResSize(){Name="M"};//master dimensions definition (two sizes, L and M)
AxdEntity_MasterDim_EcoResProductMasterSizesizeDimensionL=newAxdEntity_MasterDim_EcoResProductMasterSize(){SizeProductMaster="MAX00002",Size="L",EcoResSize=newEcoResProductMasterRef.AxdEntity_EcoResSize[1]{ecoResSizeL}};AxdEntity_MasterDim_EcoResProductMasterSizesizeDimensionM=newAxdEntity_MasterDim_EcoResProductMasterSize(){SizeProductMaster="MAX00002",Size="M",EcoResSize=newEcoResProductMasterRef.AxdEntity_EcoResSize[1]{ecoResSizeM}};AxdEcoResProductMasterDimValueaxdDimValue=newAxdEcoResProductMasterDimValue(){MasterDim=newAxdEntity_MasterDim_EcoResProductMasterDimensionValue[2]{sizeDimensionL,sizeDimensionM}};EcoResProductMasterRef.CallContextmasterDimctx=newEcoResProductMasterRef.CallContext();EcoResProductMasterDimValueServiceClientmasterDimensionService=newEcoResProductMasterDimValueServiceClient();try{masterDimensionService.create(masterDimctx,axdDimValue);}catch(Exceptione){System.Console.WriteLine(e.Message);System.Console.ReadKey();}}
staticvoidcreateVariant(){//product variant definitionAxdEntity_Product_EcoResDistinctProductVariantproductVariant=newAxdEntity_Product_EcoResDistinctProductVariant(){DisplayProductNumber="MAXL",ProductType=AxdEnum_EcoResProductType.Item,SearchName="MAXL",ProductMaster="MAX00002"};productVariant.Translation=newAxdEntity_Translation[1];productVariant.Translation[0]=newAxdEntity_Translation(){LanguageId="en-us",Name="Max L size"};productVariant.VariantDimValue=newAxdEntity_VariantDimValue_EcoResProductVariantDimensionValue[1];productVariant.VariantDimValue[0]=newAxdEntity_VariantDimValue_EcoResProductVariantSize(){DistinctProductVariant="MAXL",ProductDimensionAttribute=3173,//The ID of the EcoResSize tableSize="L",EcoResSize=newEcoResProductRef.AxdEntity_EcoResSize[1]{newEcoResProductRef.AxdEntity_EcoResSize(){Name="L"}}};AxdEcoResProductaxdProduct=newAxdEcoResProduct(){Product=newAxdEntity_Product_EcoResProduct[1]{productVariant}};EcoResProductRef.CallContextinventDimctx=newEcoResProductRef.CallContext();EcoResProductServiceClientproductService=newEcoResProductServiceClient();try{productService.create(inventDimctx,axdProduct);}catch(Exceptione){System.Console.WriteLine(e.Message);System.Console.ReadKey();}}