How to schedule Dynamics GP to automatically log in and run an Integration Manager integration
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
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
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 308569 - How to Schedule a Task in Windows XP
TechNet article 906020 - Windows 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/
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 2
Logging 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 sheLL
NewActiveWin 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 sheLL
NewActiveWin dictionary 'default' form sheLL window sheLL
NewActiveWin dictionary 'default' form syReminders window syReminders
MoveTo field '(L) btnClose'
ClickHit field '(L) btnClose'
NewActiveWin dictionary 'default' form sheLL window sheLL
NewActiveWin 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
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
KB article 308569 - How to Schedule a Task in Windows XP
TechNet article 906020 - Windows 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/
Comments
Great post as always.
I'm a stickler for spelling. I couldn't help notice the misspelling in the 3rd paragraph from the end.
"Once the batch has been created, we can use Microsoft Widows Task Scheduler...."
Looks like we need to schedule work for widows to do.
Thanks for the laugh.
Japheth
As always, much thanks for the comment and for being a good reader. My laptop's keyboard is a bit hard and not always responds not my fat fingers. I guess I will use a hammer next time :-)
MG.-
Mariano Gomez, MVP
http://www.maximumglobalbusiness.com
David
Thanks for your inquiry. I appreciate you following this article.
Unfortunately, the macro system is not a fail-secure system. If an unexpected dialog appears during execution of a macro, there will be no way for the macro itself to respond to the dialog box (unless the dialog appeared during recording and an action taken).
Hope this helps,
MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
I'm trying out the shortcut workaround to execute Integration Manager. But somehow it doesn't work for me.
Here is what I did.
1) I added an "external shortcut" to the Navigation Pane
2) Entered the path to my ...IMRun.exe with /I "(Integration Name Here)"
3) When I clicked on the shortcut following message showed up.
"The File doesn't exist in the specified location"
So I guessed that putting the parameter when specifying the "external shortcut" wouldn't work, because it assumes that it's a file, instead of a command line.
To get some kind of result, I did the following and it worked.
1) I created a shortcut to my IMRun.exe, adding the parameter like you specified.
2) Double clicking it will run the specified integration without having to select the integration from list.
3) So I created an external shortcut in GP, to the shortcut that I just created.
4) It worked just fine, EXCEPT one part.
Once the integration finishes, the log window closes itself automatically. I'd like to keep this window open, so that each time I run the IM, I can check if it failed or not.
Do you have any suggestions?
Thank you!
ps. and sorry for the long post.
Kenji
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.
I know where all the confusion stems from. I will be correcting the article to reflect the changes, but in the mean time, what I meant was, if you create a batch file (say for example, execIntegration.bat) within the directory where the IMRun.exe resides, and if you add the line
Microsoft.Dynamics.GP.IntegrationManager.IMRun.exe /I "YourIntegrationHere" /S
to the batch, you should be able to add a shortcut to the batch on the navigation pane. The shortcut for the batch can now be used within a macro.
Note the /S parameter, which will allow you to run the integration in silent mode.
Best regards,
MG.-
Mariano Gomez, MVP
Maximum Global Business, LLC
http://www.maximumglobalbusiness.com
Thank you for your quick response!
Well, that explains things really well.
You mentioned about /S, which runs the IM in Silent Mode. Is there an opposite parameter for this?
I mean I'd like to keep the IM window open after the Integration finishes. Right now, the window automatically closes, and to check it's error and other status I need to manually open IM.
If there is such a parameter, it would be great.
Thank you!
Kenji
Thanks!
Also, the instructions for starting GP from the command line seems to be incorrect, or there is something missing. The first command launches Dexterity Runtime, which hangs and the next command cannot be invoked. If you close the Dexterity Runtime window, then the next command runs, but you get "Windows cannot open this file" referencing Dynamics.set. If you cancel this, then you get the same thing for your macro.
Best regards,
MG.-
Mariano Gomez, MVP
Best regards,
MG.-
Mariano Gomez, MVP
I am still having difficulty with my login macro. I originally set up the macro by running the commands in GP one at a time for 60companies. Now I need to add some new companies to the macro, and I do not want to create a new one from scratch. However, I don't know the Item #'s for the new companies or whether the Item #'s have changed for the original companies.
If your integration is supposed to run through all 60 companies, what difference does it make what position the company appears in the drop down?
Just replicate the section of the macro and change the item number.
MG.-
Mariano Gomez, MVP
Very splendid post, saved lots of hassles actually.
well i ran into such scenario like below, using macro to start GP and run integration.
1. start GP (from command line)
2. initiate integration from Navigation Pane shortcut (external shortcut pointing to startIM.cmd)
the thing is, once the integration finishes, GP does not quit and stays open. so i added cmdQuitApplication to the end of my login.mac
Logging file 'macro.log'
CheckActiveWin dictionary 'default' form Login window Login
MoveTo field '(L) SQL_DataSource'
ClickHit field '(L) SQL_DataSource' item 4 # 'SQL2K'
MoveTo field 'User ID'
TypeTo field 'User ID' , ''
MoveTo field Password
TypeTo field Password , ''
MoveTo field 'OK Button'
ClickHit field 'OK Button'
NewActiveWin dictionary 'default' form sheLL window sheLL
NewActiveWin dictionary 'default' form 'Switch Company' window 'Switch Company'
ClickHit field '(L) Company Names' item 1 # 'Fabrikam, Ltd.'
MoveTo field 'OK Button'
ClickHit field 'OK Button'
NewActiveWin dictionary 'default' form sheLL window sheLL
NewActiveWin dictionary 'default' form sheLL window sheLL
# You have chosen to use the sample company, which provides data that you can use to practice procedures or learn more about the product. When you use this sample company, the date is automatically set to April 12, 2017.
NewActiveWin dictionary 'default' form DiaLog window DiaLog
ClickHit field OK
NewActiveWin dictionary 'default' form sheLL window sheLL
ShellCommand 'Navigate to \cmdListShortcutBar\startIM' # startIM
CommandExec form BuiLtin command cmdQuitApplication
the problem now, before integration is started, the macro had already logout GP. am i missing out any important step?
Thanks very much for your help.
Worm
Dynamics V9 - perfect
Dynamics GP 2010 - not so much!
Windows Server 2003
A disconnected session always logged in.
Windows Scheduled Task (run only if logged in)
Fires a .bat to start GP with .set and .mac parameters.
The macro ONLY logs into a company.
Then, have a Startup folder option fires another batch file which runs IMRUN.exe
A very frustrated,
Gary.
I am trying out running the Integration from GP by creating a External Shortcut and this is my command, please let me know is there something wrong that I am doing and what parameter | is
C:\GPApplication\Integration Manager\Microsoft.Dynamics.GP.IntegrationManager.IMRun.exe/| "Inventory Item"
Help Highly appreciated