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.

10 thoughts on “Selective Modification Timestamp

  1. Darren Burgess

    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.

    Reply
    1. Kevin Frank Post author

      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.

      Reply
      1. Kevin Frank Post author

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

        Reply
  2. Bruce Robertson

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

    Reply
    1. Kevin Frank Post author

      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

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s