How to schedule Dynamics GP to automatically log in and run an Integration Manager integration

January 8, 2009

One very common request by users and organizations using Microsoft Dynamics GP and Integration Manager is the ability to schedule an integration to run overnight. For small companies this can become a challenge, more so, when they lack the technical resources on staff or the basics on the Dynamics GP architecture.

The Basics

Any of the approaches used to schedule the integration will start from the same point: creating a login macro. The steps to create a login macro are widely documented in the Integration Manager Users Guide printable manual, in Chapter 17, under the section Recording the Login Macro, hence will not be the focus of this article. However, here is a sample of what the macro file (conveniently named LOGIN.MAC) should look like.

LOGIN.MAC macro

# Created by Mariano Gomez, MVP# Sample Dynamics GP Login Macro.# This sample code is provided "AS IS" and conferes no rights express or implied## FILE: LOGIN.MAC## DEXVERSION=10.0.313.0 2 2Logging file 'IMMACRO.LOG'CheckActiveWin dictionary 'default'  form Login window Login  MoveTo field Password  TypeTo field Password , 'p@ssw0rd'  MoveTo field 'OK Button'  ClickHit field 'OK Button'NewActiveWin dictionary 'default'  form sheLL window sheLLNewActiveWin dictionary 'default'  form 'Switch Company' window 'Switch Company'  ClickHit field '(L) Company Names' item 1  # 'Fabrikam, Inc.'  MoveTo field 'OK Button'  ClickHit field 'OK Button'NewActiveWin dictionary 'default'  form sheLL window sheLLNewActiveWin dictionary 'default'  form sheLL window sheLLNewActiveWin dictionary 'default'  form syReminders window syReminders  MoveTo field '(L) btnClose'  ClickHit field '(L) btnClose'NewActiveWin dictionary 'default'  form sheLL window sheLLNewActiveWin dictionary 'Support Debugging Tool'  form 'MBS_Debugger' window 'MBS_Debugger'CloseWindow dictionary 'Support Debugging Tool'  form 'MBS_Debugger' window 'MBS_Debugger'NewActiveWin dictionary 'default'  form sheLL window sheLL 

NOTE: Your macro must close all windows opened upon startup of Dynamics GP for Integration Manager to proceed successfully. In addition, you will manually need to edit the file to include the line in red above to prevent displaying any message generated by the macro execution.

Macros and running Integration Manager from inside Dynamics GP

The macro system has a limitation when it comes to executing integrations from within the Dynamics GP application: macros cannot interact with Win32 applications menus and options. Hence, if you attempt to use the Run Integration menu option found under Microsoft Dynamics GP > Tools > Integrate > Run Integration, and while GP will launch the Microsoft.Dynamics.GP.IntegrationManager.IMRun.exe application (IMRUN for a short), the macro system will not be able to record the extra click on the integration you want to execute after the IMRUN application is launched.

*Click on image to enlarge

However, there is a workaround! The macro system can interact with the Dynamics GP Shortcut Navigation Bar. If you add a shortcut to the Dynamics GP Navigation Bar to include the IMRun application with the integration to be executed as a parameter, your macro can record the action when you click on the shortcut.

* Click on image to enlarge

Scheduling the Integration

I have worked with clients solving the issue of scheduling without resorting to add-ons or complex scheduling applications.

Batch Files and Windows Task Scheduler

Batch files can still prove very useful, even in today’s GUI-based world. The batch file technique will require executing Dynamics GP with the log in macro as a parameter to the launching process. In addition, the login macro must contain additional actions to run the integration from the Navigation Bar, as previously described.

The following is a sample batch file named IMEXEC.BAT

IMEXEC.BAT

:::: Created by Mariano Gomez, MVP:: FILE: IMEXEC.BAT:: Sample batch file to launch GP and run an integration:::: This sample code is provided "AS IS" and conferes no rights express or implied::C:\Program Files\Microsoft Dynamics\GP\DYNAMICS.EXE C:\Program Files\Microsoft Dynamics\GP\DYNAMICS.SET C:\Program Files\Microsoft Dynamics\GP\DATA\LOGIN.MAC

Once the batch has been created, we can use Microsoft Windows Task Scheduler to complete the scheduling process. The following Microsoft Knowledgebase and TechNet articles will help with scheduling the batch file based on your operating system:

KB article 308569How to Schedule a Task in Windows XP
TechNet article 906020Windows Vista Task Scheduler

I will address running integrations as separate tasks in a future installment. This will allow for discussion of more advance scheduling techniques.

Other Resources

Windows Networking – Working with the Windows Server 2008 Task Scheduler (Part 1).
Windows Networking – Working with the Windows Server 2008 Task Scheduler (Part 2).
Dynamics GP Blogster- Macros in Micrsoft Dynamics GP v 10.0. Click here.

Until next post!

MG.-
Mariano Gomez, MIS, PMP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com/