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

december

02dec9:00 am12:00 pmOnline Workshop - Dynamics GP Year End Close (Morning Session)

03dec11:00 am12:00 pmConfab with Stoneridge - Livestream: Live Agents, Power Virtual Agents, Omnichannel – Oh My!

03dec1:00 pm4:00 pmOnline Workshop - Dynamics GP Year End Close (Afternoon Session)

09dec10:00 am10:30 amThe Modern Manufacturer - Manufacturing Policy Management

17dec11:00 am12:00 pmConfab with Stoneridge - Livestream - Technology in 2020: A Year in Review

january

06jan10:00 am10:30 amThe Modern Manufacturer - MRP v MPS – What, When and How

14jan11:00 am12:00 pmConfab with Stoneridge - Livestream - Looking Forward: Predictions for Technology in 2021

20jan10:00 am10:30 amThe Modern Manufacturer - Demand Forecasting Functionality

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