02-07-2011 07:06 AM
Hi there, I need some info on how to achieve that the program executes a specific script, whenever the client closes the application.
I do know, that "DB Open" and "DB Close" scripts, under the tools-options-client plugging tab, on the administrator program, are no longer used (not recommended), and instead, I read something regarding using this piece of code:
sState = Application.State
If sState = "3" Then
'Do whatever you want to do before the close of the program...
but not sure where to put this piece of code..
Any suggestions on how to use that or how to achieve my goal any other way?
Best regards and thanks in advance
02-07-2011 09:51 AM
I don't know who told you that the DBOpen/Closed events are no longer used/recommended.. but I have never heard that.
At the Global events(Scripts) level there is a logon complete type of event.. but like DB OPen/Close, it fires everytime you do a ctrl-F5.
Our "User-Tracking" application uses both the "Login (at the global event level) as well as the DBClose(ing...) to enable some control in realtime over users (client app version info (to teh build level).. lockout logins, etc.
02-08-2011 02:05 AM
Hi again RJ and thanks, this is where i read not to use DBOpen:
anyway, i tried that way (using a DB Open script) but, as the script i want to execute performs a call for a .net extension, that must return a result (true or false), this script doesn't seems to works
It appears to me, like if the .net extensions are deleted by the time this script "DB Close" is executed.
Let em explain what is my intention:
I want to execute a script, so when the user exits from slx, checks if that user is logged out from other "outside" system, and if not, i want the user to be logged out from that "outside" system....I can achieve this from within the SLX application, when the user hits a button, using a call to a .net extension that logs out the system, but if the user forgot to do this prior to exit SLX, i want to make sure that it's logged out.. And that's why i need this call to a .net extension is executed on the "ON EXIT" of the SLX program..(no matter where the user is placed: accounts, contacts, tickets...)
How can i achieve this, if the .net extensions seems not to be working on that "db close" scripting-time?
I hope you understand what i'm trying to do.
02-08-2011 05:36 AM
Ah.. HA!... Yes.. it is not advisable to depend on "DBOpen" .. and this is why:
The DBOpen event firing is very non-deterministic. It appears (after very thorough testing by many of us) it is really a "DBOpening" event and not everything is settled down. (FYI.. DBClose is really DBClosing..... and the DB is still really accessable.. for a short - non-deterministic window.. but time enough to update or add a record.. maybe a couple..)
What you want to be using as a very reliable "opened" event is: Application_LogonComplete at the Global Event Handler(script) level. Yes, I said Global "Event Handler".. not scripts.. even though SalesLogix calls them scripts. To understand this you should open teh Architect help and search for logon. You should find a topic on: Creating a Global Script. This should help get you started.
Warning.. GS's require you to be completely logged out of SalesLogix and back in.. a ctrl-F5 will not cut it for a refresh on a GS. .. and do NOT put a msgbox on code in a GS.. they are event handlers and msgbox's will throw the timing off producing false results. - use the "Application.Debug.Writeline" approach.
Oh yes.. LogonComplete actually happens AFTER the environment and db are settled down.. and will happen after EVERY Ctrl-F5 (even though many of us feel that is incorrect design.. should be once.) . Watch out for the "hooking" data in the help ;-)