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


Deleting Source Files from Archive Folder
The Sales Header does not exist. Identification fields and values: Document Type=’Quote’No.=’’
How to Exclude Data Source Rows
SmartConnect - Extra Source Records
RM Apply Detail SmartList Builder Template

POPULAR POSTS


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

CATEGORIES

ARCHIVES

open all | close all

TAGS

CRM Dynamics 365 dynamics crm Dynamics GP Dynamics NAV Econnect Employee Spotlight eone eOne News eOne Spotlight ERP Events Excel Excel Report Builder Extender Extender Enterprise Flexicoder GP GPUG integration integration manager Meet the Team Microsoft dynamics crm Microsoft Dynamics GP Office Relationships partners Popdock release Reporting SalesForce SalesForce.com scripting SmartConnect SmartConnect.com 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.