Creating a Support Debugging Tool Non-Logging Trigger to run after login

David Meego - Click for blog homepageThis little hint might be handy if you are trying to use the Support Debugging Tool to create a non-logging trigger to run some code after a user logs in.

The Support Debugging Tool uses a trigger after the Add_Successful_Login_Record global procedure (see more information below) to start its initialization after a user has logged in. Part of this process is starting triggers marked to Automatically Start on Login.

So the question is: What event can I trigger on that happens AFTER the triggers are initialized so that I can run my SDT created trigger when a user logs in?

Well, I had to answer this question myself recently as I wanted to run some code to compare the SQL User ID used to log into Microsoft Dynamics GP with the Windows User ID currently in use on the machine. The site in question created the SQL User IDs to match the Windows User IDs and this script was meant to detect when users logged into Microsoft Dynamics using a different Dynamics User ID to their Windows User ID.

The solution is use a procedure trigger on the global procedure SQM_StartForApp. This procedure is called just after the Add_Successful_Login_Record global procedure.

Below is the script I used for the User ID example. This runs as a non-logging trigger in the context of the Microsoft Dynamics GP dictionary:

Conditional Script Example

out boolean OUT_Condition;

local string compiler_error;
local string l_user;

OUT_Condition = false;

if execute(5261, "inout string INOUT_User; INOUT_User = GetUserName();", compiler_error, l_user) <> 0 then
{A compiler error occurred. Display the error.}
error compiler_error;
end if;

if l_user <> 'User ID' of globals then { Insert Condition Here }
call with name "MBS_Auto_Log" in dictionary 5261, "Windows User: " + l_user + " SQL User: " + 'User ID' of globals;
OUT_Condition = true;
end if;

 

NOTE: This code obtains the Windows User ID by calling the GetUserName() function in the Support Debugging Tool dictionary (5261) using some passthrough sanScript and the execute() function.

You can also import the Debugger Settings Login Check.dbg.xml Support Debugging Tool Configuration Settings file which is attached to the bottom of this post.

For more information see

Hope this is useful. 

David

// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, https://opensource.org/licenses/ms-pl.html.)

Debugger Settings Login Check.dbg.zip