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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Opening a XML file with dynamic file name

(1) ShareShare
ReportReport
Posted on by 530

Hi, I have to use XML files to import data into AX. There is a folder where files will be placed, the problem is that each time a file is available for in the folder it has a different file name. The file name carries the time stamp and other details in this format "Source_Destination_Module_YYYYMMDD_HH24MMSS.xml". So, filenames will always be unique. 
Kindly tell me a solution using which I can import files with unique file names.

Note: This is the method I use for XML files "xmlDoc.load(”c:\temp\AX_PEPS_AP_20150604_01241059.xml”);"

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi Osama.

    Have a look at dynamicsuser.net/.../171187.aspx

    It describes how to read all the files in a folder. You can just add an if to only process files ending  in .xml.

  • Verified answer
    Community Member Profile Picture
    on at

    If there is going to be one file in folder always then you can browse the folder for files and import the available file. However, if you have multiple files in folder and you only need to pick the last one created, even in this case you have to write logic for fetching filenames from folder. On the second phase remembering files which were read before you may store filename in AX which is obviously not good solution, you can move files after importing to some archive folder or  you can delete the file after import.

  • Osama Anjum Profile Picture
    530 on at

    Can I use the same method in an AX bacth job?

    I need to run a batch job every 5 minutes that looks into the folder and picks the first created file in the folder and moves it to another folder. Will this same logic work in this case as well?

  • Community Member Profile Picture
    on at

    Yes you can.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans