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

# 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
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 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

Japheth Nolt said…
Mariano,
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
Mariano Gomez said…
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
Anonymous said…
What if an unexpected dialog box appears? Can the the script recover from that? If so, how?

David
Mariano Gomez said…
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
Anonymous said…
Mariano,

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.
Mariano Gomez said…
Kenji,

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
Anonymous said…
Mariano,

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
John said…
I am running a macro to login and click on an external shortcut in GP 9. However, the macro is not picking up on the clicked item. In GP 10, this action was recognized by the macro. Any ideas why GP 9 is not recognizing the clicked shortcut?

Thanks!
Anonymous said…
It seems ther are several unresolved issues with this concept. As the previous posting states, in GP 9 the macro recorder does not record the clicking of the external shortcut. Instead, the macro records everything that occurs after the shortcut is clicked (i.e. all the transactions that are being integrated are recorded into the macro).

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.
Mariano Gomez said…
All these steps were tested with Dynamics GP v10 on Windows Vista. I have not tested any other configurations, so I cannot really comment on them.

Best regards,

MG.-
Mariano Gomez, MVP
JayStar said…
Two questions re: scheduling auto login sequentially to several GP companies: The login macro contains an Item # for each company. If I am modifying an existing macro to add new companies, where do I get the Item #? And does the Item # change for existing companies if new companies are created in GP?
Mariano Gomez said…
The Item # corresponds to the sequence of the company within the company drop-down. This value may vary by user, since different users may have different access to different companies. You can take a look at this article for more info: http://dynamicsgpblogster.blogspot.com/2009/03/how-to-determine-what-company-was.html

Best regards,

MG.-
Mariano Gomez, MVP
JayStar said…
Mariano,

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.
Mariano Gomez said…
JayStar,

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
Anonymous said…
Mariano,

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
Ralph Wahlert said…
Can this be achieved in GP2010? I have the marco for logging in written but it doesn't seem to run. I get to the welcome screen and does not advance past this screen. I have done this before, but it was in a much older version. Has the ability to auto login been removed?
Anonymous said…
Has anyone had any experiences with APPCRASH dumps when using the method described?

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.
Anonymous said…
Hi There,

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

Popular posts from this blog

DBMS: 12 Microsoft Dynamics GP: 0 error when updating to Microsoft Dynamics GP 2013 R2

Cannot insert the value NULL into column 'CONTACT' error when clicking on Items List in Navigation Pane

How to uninstall Microsoft Dynamics GP 10.0 if you cannot uninstall it by using the "Add or Remove Programs" feature