July 17, 201312 yr 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!
July 17, 201312 yr 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.
July 17, 201312 yr 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.
July 17, 201312 yr 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.
July 17, 201312 yr 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?
July 17, 201312 yr 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.
September 29, 201312 yr 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