Search code examples
filemaker

override last-edit field auto-calculation in FileMaker 19


I have a table that has auto-calculated fields for who (name) and when (date) the row was last changed, using the normal FileMaker field definitions and a protected field.

However, I have one use case where I copy data into this table, from a source that also has these entries, and I want to copy them as well. But when my script copies the data, it triggers the auto-calculation, and in the end, my "changed at" is set to the current time and "changed by" to the current user. I want to retain whatever my external source has in these fields.

How can I temporarily disable the auto-calculation for these fields in FileMaker, so that for the duration of my script, they act as normal fields and simply take the data I enter?


Solution

  • Change your auto-entered modification fields as follows

    • Switch to auto-enter Calculated value
    • Switch 'Do not replace existing value of field (if any)' off

    Then set the auto-enter calculation to something like the following

    Let ( trigger = GetField ( "" ) ; If ( $$SilentSync > 0 ; Self ; Get ( CurrentDate ) ) )
    

    You'll need to change the Get ( CurrentDate ) to whatever is appropriate for that field, and you'll need to do this for all modification fields in every table.

    After this these fields will work as normal during day-to-day editing etc.

    When setting data during your sync you can use the following at the beginning of the sync process

    Set Variable [$$SilentSync: 1]
    

    Then clear $$SilentSync at the end of the sync process

    Set Variable [$$SilentSync: ""]