Skip to content
+1-888-319-3663

HELP ARTICLE

SmartConnect – Zip File as Source


Using a Zip file as a SmartConnect Source

By default, we can’t use a zip file within SmartConnect as a data source directly, however we can write a pre-map script to extract the contents of the zip file.

This article is for the on-premise version of SmartConnect only and has only been verified with SmartConnect 20.18 and newer.

 

Script Namespaces

To begin, we need to add some .NET script namespaces to SmartConnect that will be used within our script. Unfortunately, the standard Script Namespace User window can’t be used for the System.IO.Compression assemblies that we need, so we’ll insert them directly into the proper SQL table.

These will insert into the ScriptNamespace table in the SmartConnect database. Be sure to change to the proper database name if not using the default name.

INSERT INTO SmartConnect..ScriptNamespace

SELECT ‘System.IO.Compression’, ‘System.IO.Compression’, 0

 

INSERT INTO SmartConnect..ScriptNameSpace

SELECT ‘System.IO.Compression.FileSystem’, ‘System.IO.Compression.FileSystem’, 0

 

After inserting these into our SQL table, be sure to restart SmartConnect.

 

 

Pre-Map Script

Create a pre-map script to get the zip file and copy the contents, most likely to another folder that would be your data source folder. 

If the filename is known, it can be hard coded as below and extracted to a folder.

VB.Net

System.IO.Compression.ZipFile.ExtractToDirectory(“C:\eOne\ZipFile\downloads\filename.zip”, “C:\eOne\ZipFile\Source”)

C#

System.IO.Compression.ZipFile.ExtractToDirectory(@”C:\eOne\ZipFile\downloads\filename.zip”, @”C:\eOne\ZipFile\Source”)

 

If the zip file is going to be different each time, then it would require looping through the directory to find the file and extract it. This would also work if there are multiple zip files in the same directory when the map is run.

VB.Net

Dim extractPath as string = “C:\eOne\ZipFile\Source”

Dim files() as string = DirectoryInfo.GetFiles(“C:\eOne\ZipFile\Downloads”,”*.zip”)

 

For Each file as string in files

  System.IO.Compression.ZipFile.ExtractToDirectory(file, extractPath)

  Next

  Return true

 

C#

string extractPath = @”C:\eOne\ZipFile\Source”;

string[] files = DirectoryInfo.GetFiles(@”C:\eOne\ZipFile\Downloads”, “*.zip”);

 

foreach (string file in files)

System.IO.Compression.ZipFile.ExtractToDirectory(file, extractPath);

 
return true;

 

 

Map

Set up the map using the Folder Data source using the Source Folder that is referenced in your pre-map script. All the extracted files will then exist in this folder and those that match the template format will be properly processed.

https://www.eonesolutions.com/Manuals/SmartConnect/SmartConnect%202018/?page=sc_folder_data_source


RECENT POSTS


Use the REST Connector to parse nested Value Arrays
SmartConnect email task fails with error: An invalid character was found in the email header
Does SmartConnect import into Avalara Avatax software
Could not initialize a collection when launching SmartConnect
ERROR [HY000] [Microsoft][ODBC Excel Driver]General error Unable to open registry key when you open a SmartConnect map.

POPULAR POSTS


SSL Security error using OLEDB Connection
This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms
Removed Part: /xl/vbaProject.bin part. (Visual Basic for Applications (VBA))
The server process could not be started because the configured identity is incorrect.
Using WINSCP and a task to upload or download files from an SFTP site

CATEGORIES

TAGS

Business Central CRM D365 Business Central Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News error Error Message Events Excel Excel Report Builder Extender Flexicoder GP integration Map Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Navigation List Builder Office Relationships partners Popdock release Reporting SalesForce SalesForce.com SmartConnect SmartConnect.com SmartConnect Bootcamp SmartConnect Maps SmartConnect Office Hours SmartList SmartList Builder SmartPost SmartView SQL Tech Tuesday Templates training

Integrate & Automate without Any Code.

SmartList Data has Never Been Faster.

The Easiest Way to Report on GP Data.