Skip to main content

Importing Products into AX 2012

EcoResProductServiceClient service = new EcoResProductServiceClient();
            CallContext ctx = new CallContext();
            ctx.Company = "ceu";
            AxdEcoResProduct axdProduct = new AxdEcoResProduct();
           
            //first, create a distinct product
            AxdEntity_Product_EcoResDistinctProduct distinctProduct = new AxdEntity_Product_EcoResDistinctProduct();
            distinctProduct.DisplayProductNumber = "Bulb60W";
            distinctProduct.ProductType = AxdEnum_EcoResProductType.Item;
            distinctProduct.SearchName = "Bulb60W";
           
           
            AxdEntity_Translation tran = new AxdEntity_Translation();
            tran.LanguageId = "en-us";
            tran.Name = "Transparent Bulb 60W";
            distinctProduct.Translation = new AxdEntity_Translation[1] { tran };
           
            AxdEntity_Identifier ident = new AxdEntity_Identifier();
            ident.ProductNumber = "Bulb60W";
            distinctProduct.Identifier = new AxdEntity_Identifier[1] {ident};
            AxdEntity_StorageDimGroup storage = new AxdEntity_StorageDimGroup();
            storage.Product = "Bulb60W";
            storage.StorageDimensionGroup = "PG_30";
            distinctProduct.StorageDimGroup = new AxdEntity_StorageDimGroup[1] {storage};
           
            AxdEntity_TrackingDimGroup tracking = new AxdEntity_TrackingDimGroup();
            tracking.Product = "Bulb60W";
            tracking.TrackingDimensionGroup = "PG_30";
            distinctProduct.TrackingDimGroup = new AxdEntity_TrackingDimGroup[1] {tracking};
           
            axdProduct.Product = new AxdEntity_Product_EcoResProduct[1] { distinctProduct };
            try
            {
                service.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.ReadKey();
            }

            //Then, release the product by calling the ItemService
            ItemServiceClient itemService = new ItemServiceClient();
            CallContext ctx2 = new CallContext();
            ctx2.Company = "ceu";
            AxdItem item = new AxdItem();
            AxdEntity_InventTable inventTable = new AxdEntity_InventTable();
            inventTable.ItemId = "Bulb60W";
            inventTable.Product = "Bulb60W";
           
            AxdEntity_Invent inventItem = new AxdEntity_Invent();
            inventItem.ItemId = "Bulb60W";
            inventItem.UnitId = "Box";
            inventTable.Invent = new AxdEntity_Invent[1] {inventItem};
           
            AxdEntity_Purch purchitem = new AxdEntity_Purch();
            purchitem.ItemId = "Bulb60W";
            purchitem.UnitId = "Box";
            inventTable.Purch = new AxdEntity_Purch[1] {purchitem};
                       
            AxdEntity_Sales salesitem = new AxdEntity_Sales();
            salesitem.ItemId = "Bulb60W";
            salesitem.UnitId = "Pcs";
            inventTable.Sales = new AxdEntity_Sales[1] {salesitem};
            item.InventTable = new AxdEntity_InventTable[1] { inventTable };
           
            try
            {
                itemService.create(ctx2, item);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.ReadKey();
            }

Popular posts from this blog

Mark All for Open Cust Trans and Open Vend Trans

We have situations where there are lots of open transactions that need to be settled against each other. This can be the case if auto settlement is turned off. One solution is to add a "Mark All" button to the custOpenTrans or vendOpenTrans forms. This button "checks" the mark checkbox on every line. The user can then uncheck several lines if needed and Update to settle the lines. The code below is an example of what we used on the open vendor transaction screen. The code is very similar on the AR side. One note: I used vendTable.AccountNum in the code below. That should be generalized to work with any buffer that is passed into the open trans form. void customMarkAll() { VendTransOpen localVendTransOpen; VendTrans localVendTrans; container conSum; int linesProcessed; ; //show wait cursor startLengthyOperation(); element.lock(); //remove all prior markings specOffsetVoucher.deleteSpe...

Print Report in Microsoft Dynamics AX 2009 through X++

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code: void clicked() {     Args                args;     ReportRun           reportRun;     SalesFormLetter     salesFormLetter;     PrintJobSettings    printJobSettings;     CustConfirmJour     custConfirmJour;     RecordSortedList    list                = new RecordSortedList(55);     SalesTable          salesTableUpdate;     ;     SELEC...

Creating Free Text Invoice through X++ code

Job: Calling class from job to run the class public void freeTextInvoicePostTestJob() { Dialog dialog; DialogField dlgCustAcc; DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1; DialogField dlgLedgerAcc; ; dialog = new Dialog("Free-Text Invoice"); dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table'); dlgCustAcc = dialog.addField(typeid(CustAccount)); dialogPeriodLengthGroup = dialog.addGroup('Ledger Table'); dlgLedgerAcc = dialog.addField(typeid(LedgerAccount)); if(dialog.run()) { if(dlgCustAcc.value() && dlgLedgerAcc.value() != '') FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value()); else throw error(strfmt("Either CustAccount or LedgerAccount info is missing.")); } } Class: Which creates the free text invoice class FreeTxtInvoiceCreatePost { } static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount) { CustInvoiceTable custInvoiceTable; ...