Sending Flat Files from Dynamics 365 for Operations to a Different Location

by | Updated January 3, 2018 | Development, Dynamics 365 for Finance and Operations

One of the challenges we have found with Dynamics 365 for Operations is the export of flat files. Recently we had to get data (as a flat file) out of Dynamics 365 for Operations and place it in a location for a separate system to process. The process had to be secure.

Initially, we were going to use the .NET Framework functionality for FTP-ing the data to an FTP site, but found that out of the box .NET does not provide the secure FTP functionality. There are many different options (some freeware, some paid). This discussion will implement a freeware version using SSH.NET (https://github.com/sshnet/SSH.NET).

The first step is to build the dll. Once built, a reference needs to be added to the Visual Studio project. One issue we found is that this reference needs to be in a location that will be available on all different environments (Development, UAT, and Production). We ended up copying the dll (Renci.SshNet.dll) to the AOS file structure, and placing it in the root of our Model (see screenshot below).

Flat files from Dynamics 365

This file was added to the Visual Studio project, and then added into version control. This allows the file to follow the project throughout the promotion of code.

The code below is part of a class that was created to allow the batching of the file upload process (which is called AFTER the file has been created and validated to exist). The code logs into the FTP site, and once successful uploads the file to the defined location.

All of the configuration information is stored in a custom table called SysFTPSiteInfo.

Below is the code for the ftp method used. Error trapping is NOT implemented in this demonstration code.

 

Related Posts

6 Comments

  1. rakesh

    This expects the file to be placed in a folder from where it uploads to FTP. Is there any way where we generate the content of the file dynamically and place it as a file in FTP ?

  2. Brandon Carmichael

    Hello Rakesh,

    Our example was not designed with the filestream in mind. But, if you can populate a filestream object with your data, it may be possible (We did not try this as were originally interested in opening the file and validating it). Based on this example, I think you could upload via the filestream object. I just have not tried to test/implement this:

    https://gist.github.com/piccaso/d963331dcbf20611b094

    Hope this help,
    Brandon

  3. rakesh

    Hi Brandon,

    Thanks for your reply !!

    D365 being on Azure , what is the folder path (and server) you the pick the file from. I want to understand what is the value you pass to ‘localfileName’ with the understanding that we don’t have access to servers in the live environment

    Regards

  4. Brandon Carmichael

    Hello Rakesh,

    I believe we used something like c:\windows\temp, as that is included by default with the OS. You will need to use something that is already there so you don’t create a new folder.

    Thanks,
    Brandon

  5. Haja

    Can you please share the github source for download also with few more steps to configure in VS?

  6. Brandon Carmichael

    Hey Haja,

    Well, the source for the ftp dll was in the following article: https://github.com/sshnet/SSH.NET
    Unfortunately I am not allowed to share out project, as this was created for a customer and not GitHub. If you need help with GitHub, I would suggest that you start here: https://visualstudio.github.com/

    Hope this helps,
    Brandon

Submit a Comment

Your email address will not be published. Required fields are marked *

Upcoming Events

march

03mar10:00 am10:30 amThe Modern Manufacturer - MRP vs. MPS – What, When and How

03mar2:00 pm2:30 pmLot Management Best Practices for Batch Manufacturers

10mar10:00 am10:30 amEnhancing the Customer Experience and Driving More Business with Dynamics 365 Customer Service

10mar2:00 pm2:30 pmThe Five Steps to Managing Sales Tax

11mar11:00 am12:00 pmConfab with Stoneridge - Livestream - Power Apps Component Framework Power Hour

17mar10:00 am10:30 amThe Modern Manufacturer: Pro Tips for your Finance Team

24mar10:00 am10:30 amUnlock the Potential of Digital Marketing with Dynamics 365 Marketing

25mar11:00 am12:00 pmConfab with Stoneridge - Livestream - The Four Keys to Choosing the Best ERP or CRM Solution

31mar10:00 am10:30 amThe Modern Manufacturer: Keys to Reporting Success

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

april

31mar01aprTraining Class: Financial Reporting W/Account Schedules for Dynamics 365 Business Central

07apr10:00 am10:30 amBoost Seller Productivity and Close More Business with Dynamics 365 Sales

07apr2:00 pm2:30 pmEnsuring Quality for Batch Manufacturers

08apr11:00 am12:00 pmJumping into the Deep End of the Data Lake

14apr10:00 am10:30 amThe Modern Manufacturer: Cost Accounting in D365

22apr11:00 am12:00 pmMoving from Manual to Automated with Strategic Automation Strategies

28apr10:00 am10:30 amThe Modern Manufacturer: Best Practices for Inventory Turn

About Stoneridge
Stoneridge Software is a unique Microsoft Gold Partner, with emphasis on partner. With specialties in Microsoft Dynamics 365, Microsoft Dynamics AX, Microsoft Dynamics NAV, Microsoft Dynamics GP and Microsoft Dynamics CRM, we focus on attracting the most knowledgeable experts in the field to our team, and prioritize delivering stellar solutions with maximum impact for your business. At Stoneridge, we are deeply committed to your results. Each engagement is met with a dedicated team, ready to provide thorough, tailored, and expert service. Based in Minnesota, we intentionally “step into your shoes,” wherever you are. We focus on what you care about, and develop trusting, long-term relationships with our clients.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X