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 :
Finance | Project Operations, Human Resources, ...
Answered

Import MT940 bank statement through x++ code

(0) ShareShare
ReportReport
Posted on by 20

Hi guys,

I have a requirement to automate the process for importing the MT940 format bank account statement. I am able to import the MT940 file manually by selecting the file format and file. I have to do the process from x++ code and schedule a batch to run every day. I have one folder where all MT940 format file stores and I have to loop through each file and import bank statements.

I am using D365FO.

Please anyone can help me.

I have the same question (0)
  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi Sandeep.Nathe,

    Where is this folder? Have a look at this blog by me. I have used Power automate to read the file and import is using recurring integration. 

  • SandeepNathe Profile Picture
    20 on at

    Thanks Vinit,

    I have checked your blog, You are using the Power automate app to get the file and import.

    But in my case, We are accessing files using SFTP on a VM and I am fetching file from VM.  I am actually looking for how to automatically select these files on VM and use it in the Import bank statement process through code(class). Later I will schedule this class to run every day.

  • Suggested answer
    vinitgoyal2005 Profile Picture
    6,332 on at

    Hi Sandeep,

    Is there a particular requirement where you have to do via X++ code only? Power automate/ logic app has become normal in integrations. With the Power platform, things are more configure rather than code. it can easily be monitored. Send notifications/Emails for failed files etc. You can add as many different things you want and all by config.  If you still want to use X++ code then you can use C# libraries to read files from SFTP. Look at community.dynamics.com/.../read-file-from-sftp, read the file content and call Recurring integrations from code via HTTP call (just mimicking what I did in Power automate)

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Please remember that D365FO is a cloud service and it can't see any VMs or local folders. So you can't have a batch that imports files from a VM.

    Instead you can use some external program that is installed in your company network (on some VM) and sends the files to D365FO.

    But even easier if you use LogicApps to read the files from SFTP and send directly to D365FO. No need for any folders in between.

  • Verified answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    If you  want to go with route of using x++ for connecting  SFTP   then you can use external libraries and  which helps you to connect to SFTP  then you have to store them in a blob storage and then pass it to  your data project . Look at the class BankStatementImportBatch   method doImportBankStatementsDMF which is responsible for importing bank statement MT940 , BAI2 in D365.

    Below link will guide for a standard set up required on the data project.

    docs.microsoft.com/.../set-up-advanced-bank-reconciliation-import-process

    If you look at this class it does the same thing , upload files in blob gets the file Id  , file name and use it later for processing those file using data project using doPGImport method.  I have written a small blog on BAI2 import  this will guide you to  store file in blob once you get those from SFTP . You can easily  automate these two task , getting file from SFTP and then passing those file

    community.dynamics.com/.../msdyn365fo-bai2-import-uploading-files-to-blob-and-splitting-files-in-one-version

    Using logic apps to connect to SFTP is  another option where you don't have to write code to get the files and then pass those to your data project.

  • SandeepNathe Profile Picture
    20 on at

    Thanks Vinit & Nicolaos,

    Will try to implement the solution using LogicApps with SFTP.

    Please can you provide any link if you have for LogicApps to read files from SFTP.

    Thank you again.

  • SandeepNathe Profile Picture
    20 on at

    Thanks Sukrut,

    This is what I am looking for.

    As you suggested I will check for Logic apps too.

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    You should be able to find documentation about Logic Apps and SFTP by searching the web for Logic Apps and SFTP.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans