web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Import Sales Lines from Excel to AX 2012

(0) ShareShare
ReportReport
Posted on by 209

I have this task to make a Import Button in a Sales Order, to import Sales Lines (Items)

here is a picture of the Sales Items Field in a Sales Order:
qsqsq.png

here is the Data Sample to be imported(the Excel):

6840.excel.png

----------

if you can give me codes of how to do this, it will be great, any other replies or suggestions are welcome. please help me. thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vinai Varghese Profile Picture
    150 on at
    RE: Import Sales Lines from Excel to AX 2012

    Hi,

    I have created a utility to import the sales order lines from a simple CSV file. Below is the link to the code.

    https://vinayofvarghese.wixsite.com/dynamicsolution/post/import-sales-order-lines

    Please test it in your UAT and pre-production servers before moving to the production environments.

    Happy DAXing!

  • Community Member Profile Picture
    on at
    RE: Import Sales Lines from Excel to AX 2012

    Hi,

    what I am suggesting is create another table same as SalesLines for history purpose and a form, first import data into that new created table using DIXF or the code in link provided by Bhaskar Roy. then use my code in button clicked event in new created form to import number of lines as you want and update imported lines in new created table.

  • XSpy Profile Picture
    209 on at
    RE: Import Sales Lines from Excel to AX 2012

    i think it doesn't get my currently opened Sales Order, because the code creates its own Sales Order from the Excel.

    I need to get my currently Opened SalesOrder and put it in code. so it will connect the SalesLine in the SalesOrder(SalesID)

  • XSpy Profile Picture
    209 on at
    RE: Import Sales Lines from Excel to AX 2012

    i need the manual coded.

    i tried using the link you suggested:

    erpdax.wordpress.com/.../importing-sales-order-sales-lines-from-excel-file

    im modifying it on my terms, but im only guessing and trying it.

    the code given also creates a Sales Order, i only need to create the Lines, i tried deleting the code that inserts the Sales Order, but there's no results.

    can you help me modify this codes:

    ------------------------

    static void MultiSalesOrdersLineImportfromExcel(Args _args)

    {

    //SalesTable      salesTable;

    //SalesLine       salesLine;

    //InventDim       inventDim;

    NumberSeq        num;

    SysExcelApplication application;

    SysExcelWorkbooks workbooks;

    SysExcelWorkbook workbook;

    SysExcelWorksheets worksheets;

    SysExcelWorksheet worksheet,worksheet1;

    SysExcelCells cells,cells1;

    COMVariantType type;

    int row;

    ;

    application = SysExcelApplication::construct();

    workbooks = application.workbooks();

    workbooks.open('C:\\Users\\mycomputer\\Desktop\\Import.xlsx');

    workbook = workbooks.item(1);

    worksheets = workbook.worksheets();

    worksheet = worksheets.itemFromName("Header");

    worksheet1 = worksheets.itemFromName("Lines");

    cells = worksheet.cells();

    cells1 = worksheet1.cells();

    num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());

    salesTable.SalesId = num.num();

    //salesTable.CustAccount = cells.item(1,1).value().bStr();

    //salesTable.initValue(SalesType::Sales);

    //salesTable.initFromCustTable();

    //if(salesTable.validateWrite())

    //{

    //salesTable.insert();

    //}

    do

    {

    row++;

    inventDim.clear();

    inventDim.InventSizeId = int2str(real2int(cells1.item(row,2).value().double()));

    inventDim.InventColorId = int2str(real2int(cells1.item(row,3).value().double()));

    inventDim.InventStyleId = int2str(real2int(cells1.item(row,4).value().double()));

    salesLine.clear();

    salesLine.initValue(salesTable.SalesType);

    salesLine.initFromSalesTable(salesTable);

    salesLine.ItemId = cells1.item(row, 1).value().bStr();

    salesLine.initFromInventTable(InventTable::find(cells1.item(row, 1).value().bStr()));

    salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;

    salesLine.SalesQty = any2int(cells1.item(row,5).value().toString());

    //salesLine.RemainSalesPhysical = salesLine.SalesQty;

    //salesLine.SalesUnit = cells1.item(row,3).value().bStr();

    //salesLine.QtyOrdered = salesLine.calcQtyOrdered();

    //salesLine.RemainInventPhysical = salesLine.QtyOrdered;

    //salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId));

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

    if (salesLine.validateWrite())

    {

    salesLine.insert();

    }

    }

    while (type != COMVariantType::VT_EMPTY);

    workbooks.close();

    application.quit();

    info("Done!");

    }

    ----------------------------

  • Suggested answer
    Nour Desoki Profile Picture
    555 on at
    RE: Import Sales Lines from Excel to AX 2012

    shafeaa.blogspot.com.eg/.../importing-purchase-orders-using-dixf.html

    it's the link how to import PO.. the same steps to SO.. entities called Sales order Header & Sales order lines.

  • 5400 Profile Picture
    7,162 on at
    RE: Import Sales Lines from Excel to AX 2012

    See, If don't want to use DIXF, you can use above mentioned excel code. where are u getting issue can you tell us exactly.

    It is very simple code.

  • 5400 Profile Picture
    7,162 on at
    RE: Import Sales Lines from Excel to AX 2012

    what suggestion are you expecting. How to use DIXF?

  • XSpy Profile Picture
    209 on at
    RE: Import Sales Lines from Excel to AX 2012

    any suggestions?

  • XSpy Profile Picture
    209 on at
    RE: Import Sales Lines from Excel to AX 2012

    yes please give me the link too for additional solution, but from what my task is, i really need to get the hard-coded one. thanks.

  • Suggested answer
    Nour Desoki Profile Picture
    555 on at
    RE: Import Sales Lines from Excel to AX 2012

    I don't understand why u want to do this even though there's a way to import sales line using DIXF.. i can send u a link how to import it if this will be a solution

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

#1
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans