4 Replies Latest reply on Sep 9, 2013 12:28 PM by psijmons

    Set field and commit record...

    PeterWindle

      For the most part, I have seen setfield work perfectly, without the need to commit a record, however, I did notice recently that I performed a set field on a related field just prior to deleting the parent record and despite the fact that I could see the value in the child record change on screen, the value in the related table DID NOT change. I needed to put a commit record after the set field before deleting the parent record.

       

      Anyone else experienced some similar behavior?

        • 1. Re: Set field and commit record...
          Mike_Mitchell

          Yes. This is normal behavior. From the Help:

           

          When possible, the Set Field script step makes the record active and leaves it active until the record is exited or committed. Scripts that use a series of Set Field script steps should group these steps together if possible, so that subsequent Set Field script steps can act on the record without having to lock the record, download and upload data, index the field, and so on, after each individual Set Field script step. These functions and record level validation are performed after the record has been exited or committed.

           


          See http://www.filemaker.com/12help/html/scripts_ref1.36.39.html#1029024.

           

          HTH

           

          Mike

          • 2. Re: Set field and commit record...

            PeterWindle wrote:

             

            I did notice recently that I performed a set field on a related field just prior to deleting the parent record and despite the fact that I could see the value in the child record change on screen, the value in the related table DID NOT change. I needed to put a commit record after the set field before deleting the parent record.

             

            As Mike points out, it is expected behavior but I agree that it doesn't seem right, Peter.  After all, one would think that deleting the parent would in fact act as a commit but what FM sees is that the parent is deleted and, since no commit has taken place, the children should revert when parent is deleted which is what you are seeing happen in the child records.  I ran into this exact situation myself and I was just as perplexed.

            • 3. Re: Set field and commit record...
              Mike_Mitchell

              Agreed. It's even stranger when you consider that a Set Field will establish a relational tie between two records (i.e., if you set the key field), but does not, apparently, push the data back to the parent database.

               

              I would speculate it's similar to the difference between Save and Commit; one is local to the client's cache, the other is visible to other clients (because it's been pushed back to the host). But that's just speculation.

              • 4. Re: Set field and commit record...
                psijmons

                On the plus side of this behaviour, it allows you to loop through records, do your thing, but if an error occurs in any of the steps (especially important on iOS), the fact that the commit has not occurred will also leave all child records unchanged.  ( transactional behaviour I think the correct term was)