Developing for Dynamics GP

by David Musgrave (Perth, Australia) and Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Running Dexterity scripts after Login or before Logout

Running Dexterity scripts after Login or before Logout

  • Comments 3

David MeegoA while back I did a post on running Visual Basic for Applications (VBA) scripts when logging into and out of Microsoft Dynamics GP. 

Recently, I was asked about the best method of capturing the same events from Dexterity.

I have seen developers use triggers after the 'OK Button' of window 'Switch Company' of form 'Switch Company' in an attempt to capture the login event.  However, just because the 'OK Button' was pressed does not guarantee that the login was successful.  In the case where the login fails for some reason, a trigger in this location will still fire and will run when the user is not logged into a company and may cause errors.

My recommendation is to use the two activity tracking scripts that are run by the system when there is a successful login or logout event.  They are the global procedures Add_Successful_Login_Record and Add_Successful_Logout_Record. But this alone is not enough....

The issue is that using triggers on these two scripts does not handle when a user returns to Microsoft Dynamics GP from the Report Writer or Modifier. So we need some additional code to handle this situation.

Below is some example code, which uses a global boolean system variable I created called 'MBS Logged In' of globals:

Startup Global Procedure

Set_Environment Global Procedure

Set_Environment_Sub Global Procedure

MBS_Toolbar_FORM_PRE Global Procedure

Set_Environment_POST Global Procedure

So code in the Set_Environment script will only be executed when actually logging into a company and code in the Set_Environment_Sub script will be executed when logging in and when returning to Microsoft Dynamics GP from the Report Writer or Modifier.  This improves on the method mentioned in the following Knowledge Base (KB) article:

A third-party customization is still triggered even if a user cannot log on to the company in Microsoft Dynamics GP (KB 943959) Secure Link

Please use the link below to look at the original VBA related article:

VBA - Running VBA scripts after Login or before Logout Example

Hope you find this method useful. 


Page 1 of 1 (3 items)
Comments Information


Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 2 and 6 and type the answer here:
  • Post