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)

Run a class when a file is created in a folder

(0) ShareShare
ReportReport
Posted on by

How is it possible to make a function in Ax 4.0 that will monitor a local Windows folder and run a class when a new file is detected inside this folder?

I'm unable to find anything that will guide me in the right direction, using Google and forum searches, when it comes to X++ and in particular the older Ax 4.0 my customer is running.

Background for this issue is that we recieve a xml file from a web front end and need to create a quotation based on this file. The class reading the xml file and creating a quotation is already up and running in Ax 4.0, but for now I need to manually trigger the class to run.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Thank you for the respons. I might have searched using the wrong keywords. I'll give it a try by using a recurring batch job with a high frequency.

    Regards

    Bredo

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You could do it via a batch like mentioned above, but that is only one option.

    You could write a simple Service application which runs in the background in Visual Studio, that monitors if the file is received, and then makes a call to AX via Business Connector through a static method in your class, that initiates the processing.

  • Community Member Profile Picture
    on at

    Hi Vilmos

    Thank you for your suggestion. Crispin suggested much the same and in fact that was my first choice, to have the application that delivers the file also starts a method in our Ax class. However I'm unsuccessfull about logging in to Ax from the C# service that we are going to run on the Ax server.

    To run a batch job every minute or so is not satisfactory for our client. We have a web front end that awaits feedback and we want to avoid any delays. I'm going back to the track of having our service start the method and will post a new question when I have some solid info on where my code fails.

    Thanks a lot to both of you.

    Regards

    Bredo

  • Vilmos Kintera Profile Picture
    46,149 on at

    This is exactly what my recommendation above is, to use BC from either their web app straight, or from a standalone service.

  • Martin Dráb Profile Picture
    237,898 Most Valuable Professional on at

    If you can use neither a batch nor a synchronous call and you need to stick to your original requirement, the solution is using FileSystemWatcher. It raises Created event when a file is created in the given folder. You'll a ,NET class library wrapping FileSystemWatcher, because you can't subscribe to events from X++, but I think you'll be able to use the library directly from AX process (via CLR Interop).

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