xochi Posted March 8, 2012 Posted March 8, 2012 In all of my fm databases, I find that having a logging table is very useful. I've created some scripts that do this : Log($msg, $severity, $user...) // adds a timestamped log message to the log table with given severity e.g. PerformScript("$msg=\"Bad error occurred in XXXX\" ; $severity=\"Error\" ; $user=\"" & Get(CurrentUser)& "\";") However, the actual script is not very fast or efficient, as it basically does this: * create a new window showing the log table (or show it if it's already open) * create a new record in the log table * fill in the fields * commit * close or hide the log window The reason that I use a separate window for the log table, rather than simply using "go to layout "Log" ; ... ; Go to layout (original layout)" is that I've found that switching layouts can cause some issues (tab panel tab is lost, portals lose their scroll position, etc.) Also, this means I can call the script from anywhere, even if the current table doesn't have a relationship to the log table. Question: is there a better way? I was wondering if there was some clever way to get the same result without switching windows or layouts?
Vaughan Posted March 8, 2012 Posted March 8, 2012 Try using a "magic key" method to create related records. This works through a global field and does not require changing layouts. http://www.filemakerhacks.com/?p=2364
xochi Posted March 9, 2012 Author Posted March 9, 2012 Try using a "magic key" method to create related records. This works through a global field and does not require changing layouts. http://www.filemakerhacks.com/?p=2364 Very cool : reading this, I had some questions. * Can this be used from any layout? Or does it need to be run from a layout that has the g_magic_key relationship? If so thats a little limiting compared to my scripted version (which has the advantage that it can be called from anywhere). * Is this multi-user safe? It should be since it uses globals. * Is this single-user recursive safe? I'm guessing it's not, since the global key value would be the same for a single user. (The scenario I'm imagining is an error that happens in the logging code itself, so that the logging code tries to log an error in the middle of logging a message. Probably not a big problem.)
dansmith65 Posted March 10, 2012 Posted March 10, 2012 the logging code tries to log an error in the middle of logging a message Be carefull when designing this; specifically look out for creating an infinite loop in your script.
Recommended Posts
This topic is 4711 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now