HELP ARTICLE

Deleting Source Files from Archive Folder


One question that can come up in SmartConnect is, “How can we delete source files that have been moved into a folder, such as an archive folder”?

This can be done by creating a task that runs before the map. We can create this task by clicking on the Tasks tab on the Map Setup window.

Then we can right click on “Tasks that run before the map”, select New Task -> Run Script.

 

 

This will open a window where we can write a script to delete these files using .Net code.

 

 

In this example, we will include logic on deleting files that are older than X number of days.

Unless you are familiar coding in .NET, this will take some research to figure out how to write it.

Below is some sample code to delete files older than 10 days. We can change the days value as needed for the specific requirements.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

As we can see in the code above, we will be able to set the directory to wherever the files we want to be deleted are stored.

The code will run through each file in that directory and delete it, if it is older than 10 days.

This is a very useful option to save space since these files have already been integrated. It also saves time by not having to manually

go and delete all these files every day.

 

Delete Files with a Certain Extension

What if we want to delete files like above, but only files with a certain extension. We can do this by updating our

.NET code from above. Let’s say that we want to delete files older than X amount of days that have a file extension “.txt”.

We can do this by adding one piece to the .NET code above. As we can see below, we added what file extension to delete behind the “GetFiles” function.

 

 

This script will now only grab files that have a “.txt” extension and delete the file if it is older than 10 days.

This is also a great option, since we may have other files in our folder that we do not want to delete.

 

 

 

 


 

RECENT POSTS


Firewall Settings for SmartConnect.com
Accessing SmartConnect after purchasing a subscription for your company
Accessing SmartConnect after purchasing a subscription on behalf of your customer
Disassociate a CRM Record
How to drop and recreate all the SmartList Builder stored procedures

POPULAR POSTS


Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))
SSL Security error using OLEDB Connection
The server process could not be started because the configured identity is incorrect.
Manufacturing Serial Trace SmartList Builder Template
Using WINSCP and a task to upload or download files from an SFTP site

CATEGORIES

ARCHIVES

open all | close all

TAGS

Business Central CRM Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News eOne Spotlight Events Excel Excel Report Builder Extender Extender Enterprise Flexicoder GP GPUG integration Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners Popdock release Reporting SalesForce SalesForce.com scripting SmartConnect SmartConnect.com SmartConnect Bootcamp SmartConnect Office Hours SmartList SmartList Builder SmartList Designer SmartView SQL Support Tech Tuesday Templates training Zendesk

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.