9 Replies Latest reply on Mar 6, 2015 6:15 AM by TSGal

    Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]

    Jeremiah_Hammond

      Summary

      Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]

      Product

      FileMaker Pro

      Version

      13v5

      Operating system version

      OS X 10.10.2

      Description of the issue

      Get( ModifiedFields ) in a calculation field in the current table returns blank when doing a Replace Field Contents[ ] across a found set. I would expect the function to keep track of each individual record's modified fields as Replace Field Contents[ ] goes through each record in the found set. It should work like other record-specific Gets, like Get( RecordOpenState ) or Get( RecordModificationCount ).

      Steps to reproduce the problem

      Do the following all in the same table:

      1. Create a regular user-modifiable field, like a first name field, age field, whatever you want.
      2. Create a modification timestamp.
      3. Create a text field with an auto-enter calculation that'll trigger when the modification timestamp changes. Have this auto-enter do something easily identifiable when Get( ModifiedFields ) is blank versus when it returns something. Here's an sample calc:

      Let( [ trigger = modTStamp ] ; If( not IsEmpty( Get( ModifiedFields ) ) ; "It works!" ; "Uh oh" ) )

      4. Get into a found set of a few records.
      5. Type a value into the user-modifiable field.
      6. Commit the record.
      7. Click into the user-modifiable field and do a Replace Field Contents[ ] to apply the current record's value to the rest of the found set.
      8. Notice the auto-enter calc you made in step 3 says "Uh oh" for all records in the found set.

      Expected result

      Get( ModifiedFields ) in a calculation in the current table should return the modified fields as Replace Field Contents[ ] goes through each record in the found set.

      Actual result

      Get( ModifiedFields ) returns blank as Replace Field Contents[ ] goes through each record in the found set.

      Exact text of any error message(s) that appear

      N/A

      Configuration information

      Get( ModifiedFields ) also returns blank when using Import Records[ ]. It seems the function doesn't work properly when doing a multi-record batch change on the data layer.

      Workaround

      None.

        • 1. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
          Fred(CH)

          Hi Jeremiah,

          Here i cannot follow you : using Replace Field Content is table-level modification as Import records, and thus, it does not open the records as a layout-level modification does.

          Bye Fred

          • 2. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
            TSGal

            Jeremiah Hammond:

            Thank you for your post.

            The reply from "Fred" is correct (Thank you!).  Replace Field Contents will keep the pointer on he current record as the table is updated.   To update the calculation for each record, instead of performing Replace Field Contents, perform a Loop so that the calculation can process each record.

            TSGal
            FileMaker, Inc.

            • 3. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
              Jeremiah_Hammond

              Sounds like I need to put in a feature request. Get( ModifiedFields ) is much more useful if it's a data-level function, instead of a layout-level function...though it feels like the function is a hybrid. Let me give you an example:

              If you have an order layout with a line items portal, and you have an unstored calculation in the order table that outputs Get( ModifiedFields ) and an unstored calculation in the line item table that also outputs Get( ModifiedFields ), they will both work as expected. If you modify a couple order fields on the layout, the order's calculation will show the modified fields, and then, without committing yet, you modify a couple fields in the line item portal, that particular line item's calculation will show its fields that were modified. In other words, FileMaker is keeping track of two different modified fields list. Doesn't feel like a "layout level" function in this case, more data level. That's why I expected Replace Field Contents and Import Records to work.

              • 4. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                Jeremiah_Hammond

                TSGal,

                I know this probably isn't your wheelhouse, but what was the original intent of this function? What use case was FMI trying to solve? Why limit it to layout-level only? If its purpose was for audit logging, why not go the distance and make it data-level?

                • 5. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                  Jeremiah_Hammond

                  Fred,

                  That's strange to me. Isn't it technically true that, on the data layer, FileMaker has to open a record before it can modify it? You can imagine a situation, though far-fetched, where it takes 5 seconds per record doing a Replace Field Contents[ ]. What if another user wanted to modify one of those records as Replace is applying the change? Wouldn't FileMaker Pro throw an error stating another user has the record locked? That to me means there's record locking (aka opening) happening on the data layer with Replace.

                  • 6. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                    TSGal

                    Jeremiah Hammond:

                    The purpose of this function is to return a list of fields that have been modified in the current record of the current table.  The Replace Field Contents keeps the record pointer on the current record, and the data performs an auto-commit in the other records of the found set, similar to import.

                    I have sent a request for more information to Testing and Development.  When I receive more information, I will let you know.  In the meantime, if you want Get (ModifiedFields) to update in the found set, use a script to loop to loop through the records and set the field to the desired value for each record.

                    I also recommend entering this as a suggestion into our Feature Requests web form at:

                    http://www.filemaker.com/company/contact/feature_request.html

                    All entries into this web form populate a database hosted and monitored by Product Management and Development.  All entries are read, discussed and considered for possible implementation in a future release.  Although I could copy your post(s) and paste them into the web form, there are a couple of questions asked on the form that only you can answer.

                    TSGal
                    FileMaker, Inc.

                    • 7. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                      Fred(CH)

                      Jeremiah,

                      Get(ModifiedField) is probably designed to be called in a script before the committing process, since the documentation talks about record is in open state. Thus your script can do some operations, for instance if specific fields were modified, and that, just before the record is committed. Then, when the record is committed, this function return an empty string. This is obviously as designed.

                      What i meant previously was following : at the end of an operation as "Import Record" our "Replace Field Content", the updated records are not still opened (except for those that the operation fail to update, because they were already opened/locked by another window or session).

                      In all case, a Commit Record step after these kind of operation has absolutely no effect because there is nothing to commit. And as expected, Get(ModifiedField) return an empty string.

                      I am not sure to understand your goal. But when you are scripting a Replace Field Content, you knows exactly what was modified (or intended to) so i assume you don't need this function.

                      A contrario, when the enduser is opening a record, doing some modifications, it may be, in some situations, very interesting to know what field were modified.

                      Sorry for my bad english, but hope that helps...

                      Fred

                      • 8. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                        Fred(CH)

                        TSGal,

                        I feel free to bring Get( ModifiedFields ) doesn't work on new record that hasn't been committed to your attention, which is, to me, much matching to a bug than an expected behavior.

                        Maybe you could attach it to your original information request to Dev Team ?

                        Thank you !

                        Fred

                        • 9. Re: Get( ModifiedFields ) doesn't work when using Replace Field Contents[ ]
                          TSGal

                          Fred:

                          Thank you.

                          The link is not related, as it involves a new uncommitted record.  I have replied to the link.

                          TSGal
                          FileMaker, Inc.