nav-left cat-right
cat-right

AutoLogin to Dynamics GP (even) After a Crash

You can use a macro for launching and Logging into Dynamics GP Automatically. The macro for login has been discussed a few times various blogs. If you are not familiar with technique for setting up a macro for login refer to following posts

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

Weekly Review: Schedule Your Macros

Auto login for Microsoft Dynamics GP!

It is handy when you want schedule some Integrations or reports. It is also very useful during development. While working on VS Tools add-in for Microsoft Dynamics GP, a developer needs to close and login again and again to deploy and test the changes

However, the limitation of this technique is if that – if GP was closed improperly/crashed last time, the macro does not work. A Message “User ID xxx is already logged in to company XXX. Would you like to view your current logins?” is displayed. Macro displays an error message or logs it and stops prematurely.

I am a fan of automations and try to make them work seamlessly. So, I was thinking what if we could create a macro which would work in both normal GP start and GP start after a crash. The solution I found is so simple that I was surprised.

 

1. Record a macro for login, after a GP crash. This macro should have steps to delete the Current User Login Activity.

2. Add a line for logging the error message to suppress any error message in the macro. You will manually need to edit the file to include the line

Logging file ‘macro.log’

3. Place the macro in the GP folder and add macro name in the GP shortcut like

“C:\Program Files\Microsoft Dynamics\GP2010\Dynamics.exe” Dynamics.set Login.mac

If you want keep macro in another folder, you can add complete paths in the shortcut

” C:\Program Files\Microsoft Dynamics\GP2010\\Dynamics.exe” ” C:\Program Files\Microsoft Dynamics\GP2010\Dynamics.set” “C:\login.mac”

4. And that’s it!!!!

 

How it works:

After a GP this macro works normally, as it was recorded for such case. This also works in case of normal GP login. On OK button click in switch company window, the macro expects the dialog box. However, when this message does not appear, it simply logs the error message.

This technique is not recommended for live company setup. It is only for the test development environments where you are sure you can delete activity of the user with verifying it.

Limitations:

You cannot combine any other tasks with login in this macro. Workaround for this limitation is you can add another macro at GP startup.

Login.mac macro:

# DEXVERSION=11.00.0349.000 2 2
Logging file ‘macro.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’
# User ID sa is already logged in to company 00 Natsource Main. Would you like to view your current logins?
NewActiveWin dictionary ‘default’  form DiaLog window DiaLog
ClickHit field OK
NewActiveWin dictionary ‘default’  form ‘Switch Company’ window ‘Switch Company’
NewActiveWin dictionary ‘default’  form ‘Switch Company’ window UserActivity
MoveTo field ‘Delete Button’
ClickHit field ‘Delete Button’
NewActiveWin dictionary ‘default’  form ‘Switch Company’ window ‘Switch Company’
ClickHit field ‘OK Button’
NewActiveWin dictionary ‘default’  form sheLL window sheLL
NewActiveWin dictionary ‘default’  form sheLL window sheLL

Leave a Reply