Skip to content
+1-888-319-3663

EONE BLOG

Tech Tuesday: Running a Process as a Pre-Map Task and ensuring it finishes before moving on to the next task


This last week I was approached by a customer that wanted to run an SSIS package (that created the data for the Map) but sometimes that task wasn’t finishing before SmartConnect needed to use the result of that task as a data source. In this instance, the desired result wasn’t to run the tasks as quickly as possible but to make sure this task was completed before we move on to the next task or process. Below we will discuss the simple steps that you can run from a script to handle this scenario:

1) Create a new Script Task on the Map Pre Tasks section to Run before the map(Inside the Map-Tasks-Map Pre Tasks-Tasks that run before the map-Right Click and select New Task-Run Script) and name it SYNC_TASK like in the image below:



2) Now we will use the following script to start a process and ensure that the next step isn’t attempted until this task completes. In our example we will simply open notepad.exe and wait to move on until the product is closed. This same methodology could be applied to a stored procedure or SSIS package or even calling an external web service. The image below shows the example in VB.NET but you can use either.



Here is the script in both VB.NET and C# formats below:
VB.NET
‘Specify the location of the Notepad.exe file
Dim filename As String = “C:\Windows\System32\Notepad.exe”

‘Specify the parameters you want to run on the file
‘This example passes in one parameter that indicates which file it should open
Dim fileparameters As String = “file.txt”

‘This next step runs the file passing in the parameters
Dim process = System.Diagnostics.Process.Start(filename, fileparameters)
‘Do not proceed until the process is complete
‘In our example, wait until Notepad.exe is closed
process.WaitForExit()
return true


C#
//Specify the location of the Notepad.exe file
string filename = “C:\\Windows\\System32\\Notepad.exe”;

//Specify the parameters you want to run on the file
//This example passes in one parameter that indicates which file it should open
string fileparameters = “file.txt”;

//This next step runs the file passing in the parameters
System.Diagnostics.Process process = System.Diagnostics.Process.Start(filename, fileparameters);
//Do not proceed until the process is complete
//In our example, wait until Notepad.exe is closed
process.WaitForExit();
return true;


3) Run the Map by selecting the Run Map function on the Ribbon while your map is selected (this can also be done from inside the map by selecting Run when it is open).


4) In our scenario, the Notepad.exe program will launch and nothing else will continue with SmartConnect until we close the Notepad.exe application. Once Notepad is closed, the rest of the map will execute as planned.


As you can see in this simple example, we can ensure a task is finished by using standard .NET functionality. 

Thanks,
Chris

Leave a Comment





RECENT POSTS


Happy Thanksgiving from eOne! - US Office Closed November 25 & 26
Popdock: What is your Locale?
Q4 2021 Partner All Hands Call - Recording Now Available
An Announcement regarding SmartList Builder and SmartView from eOne Solutions
Join us for the Q4 2021 Partner All Hands Call!

POPULAR POSTS


2016 SmartConnect Integration Bootcamps
Tech Tues: Automatically refreshing Pivot Tables in Excel Refreshable Reports
Happy Thanksgiving from the eOne team!
2017 SmartConnect Integration Bootcamps
New Releases of Extender and SmartList Builder

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.