Jump to content

  •  

UPGRADE DEADLINE - SEPTEMBER 26, 2014!
FileMaker Inc. has a deadline for users of version 10,11, 12 as Individual box or volume licenses (with expired maintenance).
If you don't renew your maintenance and upgrade to FMP 13 you will no longer be eligible to upgrade, at the discount pricing.

Volume Licensing upgrade pricing for FileMaker Pro 13, FileMaker Pro 13 Advanced and FileMaker Server 13 will be discontinued.
Individual upgrade pricing for FileMaker Pro 13 and FileMaker Pro 13 Advanced will increase after September 26, 2014.
As of 27-September-2014, FileMaker 10 products will no longer be available for purchase or support.

http://help.filemaker.com/app/answers/detail/a_id/13865


Photo

Logging messages to a Log table


  • Please log in to reply
4 replies to this topic

#1 xochi  veteran

xochi
  • Members
  • 692 posts
  • FM Application:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Expert
  • Membership:TechNet
  • Time Online: 1d 13h 42m 4s

Posted 08 March 2012 - 08:47 AM

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?
  • 0

#2 dansmith65  veteran

dansmith65
  • Members
  • 858 posts
  • LocationB.C. Canada
  • Certification:8, 11, 12, 13
  • Membership:TechNet
  • Time Online: 14d 23h 52m 41s

Posted 08 March 2012 - 10:09 AM

You could use an SQL plug-in.
  • 0

#3 Vaughan  Mostly Harmless

Vaughan
  • Moderators
  • 10,294 posts
  • LocationSydney, Australia
  • FM Application:13 Advance
  • FMGo:iPhone / iPod Touch, iPad
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:8, 9, 10, 11
  • Membership:TechNet
  • Time Online: 4d 9h 48s

Posted 08 March 2012 - 03:11 PM

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
  • 0
Vaughan Bromfield
Sydney, Australia

Please post questions to the Forum, not directly to me. Back-up your files before making changes!

Whenever I hear the term "popular culture" I reach for my Iridium Q-36 Space Modulator.

#4 xochi  veteran

xochi
  • Members
  • 692 posts
  • FM Application:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Expert
  • Membership:TechNet
  • Time Online: 1d 13h 42m 4s

Posted 09 March 2012 - 10:38 AM

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.)
  • 0

#5 dansmith65  veteran

dansmith65
  • Members
  • 858 posts
  • LocationB.C. Canada
  • Certification:8, 11, 12, 13
  • Membership:TechNet
  • Time Online: 14d 23h 52m 41s

Posted 09 March 2012 - 09:24 PM

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.
  • 0




FMForum Advertisers