Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Conditional modification timestamp that updates only if certain fields change

Featured Replies

I have come up with a timestamp auto-enter calculation that updates conditionally only if a value in certain fields change.  For example, Table I has fields a, b, c, d, and e.  This mod timestamp should update only if the value in b, c, or d changes (it will be a separate field from the housekeeping mod timestamp of the table that updates on all changes).

 

I've tried something like:

 

Let ( ~trigger = b or c or d ; If ( ~trigger ; Get ( CurrentHostTimestamp ) ; Self ) )

 

This appears to render the desired behavior.  I am most interested to get the opinion of some experts about whether this is a safe method for accomplishing this.  Are there any gotchas I should be aware of before I move forward with implementing this?

 

There is also one other question in addition to this.  Most of the fields I need to include in this mod timestamp have a key piece of nomenclature, in that the field names all start with 'field_' .  It would be nice if I could do a single calculation to capture all these fields in one step, but I can't seem to figure out how to accomplish this.  I can just list all the fields individually, but this wouldn't be self-calibrating should I add another of these 'field_' fields to the table in the future.  I was curious if anybody had any clever ideas about how this might be accomplished.

 

Thanks for any advice you might have!

Solved by jbante

Go to solution

I routinely use something very similar to your calculation when I need this sort of modification timestamp. However, the If ( ~trigger ... ) part is unnecessary — you can just put Get ( CurrentHostTimeStamp ) there. The auto-enter calculation will already only update if one of those fields updates.

 

There is a way to get all the field names for a table, and all the names that start with "field_" could be parsed out with a custom function, but that wouldn't work for this application. The auto-enter calculation needs a vanilla direct field reference to trigger an update.

What about 

 

LimitedModTS = Evaluate("Get ( CurrentHostTimeStamp )";[b; c; d] )

 

Jeremy, I read oilcan's request as one field that would update a timestamp if only certain other fields were modified.  I don't understand how an auto enter would identify only those certain fields.

  • Solution

The auto-enter (replacing existing contents) re-calculation will only be triggered when fields referenced in the calculation are modified, thus the ~trigger Let statement and your own use of the Evaluate function. Modifications to fields not referenced in the auto-enter calculation will not trigger it to re-evaluate.

 

I've tried something like:

 

Let ( ~trigger = b or c or d ; If ( ~trigger ; Get ( CurrentHostTimestamp ) ; Self ) )

 

Do you only need the timestamp, or would you like to know who and what fields were modified?

  • Author

thanks for the feedback guys.  Sounds like my proposed method, or doughemi's method would both work for my needs.  Too bad there probably isn't a way to hook all the fields with a single sneaky calculation, but such is life sometimes.

 

@Lee, I only need the timestamp.  It's part of a timestamp based sync method, I don't really care by whom or which fields got updated, I only care to have the timestamp update if the fields in question are updated while avoiding timestamp updates on fields that are not synchronized, causing an unnecessary resync of that record with no changed data in the relevant fields.

  • 2 months later...

Look up UltraLog on Google.

 

I use UltraLog and pass to it a list of fields in a global variable.

 

The global variable is set up when the file is opened. It get's the list of all fields from the table:

 

ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName='" & "my_table" & "'" ; "" ; ""  )

 

But if you wan't only fields that start with "field_", then you'd change the ExecuteSQL statement to :

 

 

ExecuteSQL ( "SELECT FieldName FROM FileMaker_Fields WHERE TableName='" & "my_table" & "' AND FieldName LIKE 'field_%'" ; "" ; ""  )

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.