General, Level: Beginner, Version: FM 8 or later

Selective Modification Timestamp

Demo file: 2010-11-25-selective-modification-timestamp.zip (requires FM 8 or later)

Have you ever wished for a modification timestamp that would only update if a user manually edited a field? In other words, a timestamp that would not update based on scripted actions, or non-field-based activity like creating, duplicating or importing records? This can be achieved in a variety of ways, but the technique here uses a simple auto-enter calc, which I was introduced to by Nick Orr at Goya Pty Ltd.

Define a timestamp field, ts_mod_selective, with this auto-enter syntax:

Let ( [
trigger = GetField ( "" ) ; // note the innovative use of GetField
ros = Get ( RecordOpenState ) ;
ies = IsEmpty ( Get ( ScriptName ) ) ;
ts = Get ( CurrentHostTimeStamp )
] ;
Case (
ros = 1 ; "" ;
ros = 2 and ies = 1 ; ts ;
ts_mod_selective // for FM 9 or later, we could use Self
// instead of specifying the field name
)
) // end let

Note: if you just want the date or time component, you can enclose all of the above in GetAsDate() or GetAsTime(). And of course, this technique can easily be adapted to work with modification account name as well.

11 thoughts on “Selective Modification Timestamp”

  1. Slick. This is going to solve a little problem I had where mod timestamps were being updated by a script, even if there were no modifications to the record. This was wreaking havoc on my MirrorSync deployment as all kinds of sync conflicts were popping up due to wonky timestamps.

    1. Thanks for writing Darren. Funny you should post this now… I was just tweaking some of my selective mod timestamps a few minutes ago to take into account that certain script triggers *are* legitimately updating the record and in those situations I *do* want the timestamp to update.

      1. Apparently it tells FileMaker to monitor all fields for modification. Perhaps someone will respond with a better answer.

  2. Kevin: so what did you do differently? Or does get(scriptName) not return anything for a triggered script?

    1. Get(ScriptName) works the same on triggered scripts as on non-triggered ones. I namespaced all my trigger scripts on this project with a “trigger: ” prefix. So I was able to do something like this…

      Let ( [
      trigger = GetField ( “” ) ; // note the innovative use of GetField
      ros = Get ( RecordOpenState ) ;
      sn = Get ( ScriptName ) ;
      isTrigger = Left ( sn ; 9 ) = “trigger: ” ;
      ies = IsEmpty ( sn ) ;
      ts = Get ( CurrentHostTimeStamp )
      ] ;
      Case (
      ros = 1 ; “” ;
      ros = 2 and isTrigger = 1 ; ts ;
      ros = 2 and ies = 1 ; ts ;
      ts_mod_selective // for FM 9 or later, we could use Self
      // instead of specifying the field name
      )
      ) // end let

  3. Great! Ultimately a relatively simple but sneaky solution to the exact issue I was looking to deal with. Works fine, many thanks

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.