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

september

02sep10:00 am10:30 amThe Modern Manufacturer - Cycle Count Management

02sep12:00 pm12:30 pmBest Practices for Work Order Planning and Routing for Field Service Companies

09sep10:00 am11:00 amWhat is Levridge? An Overview of the Ultimate Ag Solution

09sep12:00 pm12:30 pmOverview of Microsoft Promotion for NAV and GP Clients

10sep11:00 am12:00 pmConfab with Stoneridge - Livestream - Field Service Comparisons

16sep10:00 am10:30 amThe Modern Manufacturer - Product Lifecycle Management

16sep12:00 pm12:30 pmHow to Upgrade to Dynamics 365 Finance and Operations: Examining Custom Code and ISV Implications

16sep2:00 pm2:30 pmScheduling and Dispatching for the Modern Field Service Company

23sep12:00 pm1:00 pmDynamics 365 Business Central Wave 2 Release Preview - An Overview of the Most Exciting New Features Coming in October

24sep11:00 am12:00 pmConfab with Stoneridge - Livestream - The Modern Workplace: Teams, Sharepoint, Outlook, Office, and AI Integration

30sep10:00 am10:30 amThe Modern Manufacturer - Return Management

30sep12:00 pm12:30 pmEmpowering Your Field Service Technicians with a Mobile Solution

october

07oct12:00 pm1:00 pmThe Three Paths to Business Central from Dynamics GP

08oct11:00 am12:00 pmConfab with Stoneridge - Livestream - The Vision and Strategy of Microsoft Business Systems

14oct10:00 am10:30 amThe Modern Manufacturer - Complex Cost Modeling

14oct12:00 pm12:30 pmGenerating Custom Inspection or Process Forms

19octAll Day22Stoneridge Connect Fall 2020

22oct11:00 am12:00 pmConfab with Stoneridge - Livestream - Stoneridge Connect Recap

28oct10:00 am10:30 amThe Modern Manufacturer - Engineering Change Orders

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