Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to import Multiple Excel from a specific folder in ax 2012

Posted on by 25

i have to import a data from multiple excel from a shared folder in ax 2012 using runbasebatch .

  • Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    You already have the code.

    But you shouldn't use it, because no code is needed. What you want to achieve is already supported by DIXF and there is no point reinventing the wheel and wasting resources to develop it again.

  • Axbeginerss Profile Picture
    Axbeginerss 25 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    can i get code to loop a folder and get the name of excel file  ??

  • Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    Remember that the best code is the one that you don't have to write, test, debug, document, maintain...

    First of all, check if your code runs on the same machine where you have the files. You may have files in client and running code on AOS.

  • Axbeginerss Profile Picture
    Axbeginerss 25 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    container createListOfFiles()

    {

       System.Array    files;

       int             fileCount;

       int             i;

       str             nextFile;

       container         listOfFiles;  

       new InteropPermission(InteropKind::ClrInterop).assert();

       info(strfmt('Search in: %1 %2',  @"C:\ReadFromExcel", '*.xlxs'));

       listOfFiles     = connull();

       //actIx           = 0;

       files           = System.IO.Directory::GetFiles( @"C:\ReadFromExcel", '*.xlxs');

       if (files)

       {

           fileCount =    files.get_Length();

           info(strFmt('Number of files in directory: %1', fileCount));

           for(i=0; i < fileCount; i++)

           {

               nextFile    = files.GetValue(i);

               listOfFiles += nextFile;

           }

       }

       CodeAccessPermission::revertAssert();

       info(strFmt('Files count: %1', conlen(listOfFiles)));

       return listOfFiles;

    }

    here--- fileCount =    files.get_Length(); is giving me zero even though there are 6 xlxs files in the folder.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,149 Most Valuable Professional on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    It's supported out of the box - you can set "Completed directory" in DIXF setup. See Recurring batch job import in AX 2012 R3 for details.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    Ok, sounds that you could do that with DIXF.

    Not sure if moving the file to another location is possible. But for that you could have some simple script that copies files from the source folder to DIXF folder AND "processed" folder.

  • Axbeginerss Profile Picture
    Axbeginerss 25 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    Client will get the data from a thirdparty and they will save those files in a shared folder .they will give us the path to access the folder.they ask us to create a batch job to read multiple excel s and once the excel is read it should move to another folder.

  • nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    Ok, so I assume you got some business requirement from your customer, and then decided that RunBaseBatch is the best/only way to solve this requirement. Correct?

    Just to make sure we can assist you in best possible way, could you share the business requirement?

    Often development a customization should be considered only if non-development options were not feasible in fulfilling the business requirement.

  • Axbeginerss Profile Picture
    Axbeginerss 25 on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    Thanks for reply Nikolaos Mäenpää

    but the requirment is to read multiple excels from a shared folder and update in Ax Tables using Runbase batch.

  • Mav Profile Picture
    Mav on at
    RE: How to import Multiple Excel from a specific folder in ax 2012

    DIXIF wont work if you are trying to upload multiple sheets of an excelworkbook into same custom entity.

    Something similar is already being discussed here at this thread .

    Thanks

    Mav

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans