9 Replies Latest reply on Dec 10, 2013 7:17 PM by WayneMuelver

    Strange error deletes field data


      I have a script for a FileMaker Go solution that is designed to re-assign a user to a particular record and then notify both the new user and the previous user of the change by email. This is accomplished by allowing the user to choose a staff member's name from a drop down as their selection for who it is to be re-assigned to. Then an on modify script trigger fires the script. First the user is asked to confim their intention, and if they do it sets variables about the current record, then changes layouts in order to enter the staff table. then it searches the staff table for the newly assigned staff member and the staff member who modified the record. More variables are set for each. Then a calculation evaluates these variables to see if they match. if they do not, two emails are sent to notify each user of the change, and the previously set variables are used to populate those emails. then it returns to a layout showing a list of records still assigned.


      That is where we run into trouble. Every time I run this script under my user account it works perfectly. Until, one particular user tries it. it works fine for them once, then the second time it freezes before switching layouts the final time. This middle layout was not intended to be seen by the user in this process and is actually intended for a different process. anyway, there is no navigation away from that layout so the user has to quit and start over. when they do, one particular field for every record that would have been in the active found set for that users's assigned records is now blank.


      I don't get it. I have recovered from the backup once already and it did it again less than an hour later. The field being erased is not even mentioned in the script that is being run when the issue occures. The user tells me that they did not leave the app in the middle of the process untill they got stuck and that they did not have any other event on their phone such as a text or call durring the process either time. Also, once the error occures for that user, it then occures under my user.


      Any ideas?

        • 1. Re: Strange error deletes field data
          Stephen Huston

          Several possibilities to consider


          Are there any trigger scripts on the layouts to or from which you do navigate in this process which might have script triggers on them. Something is taking you to that wrong layout, and even possibly committing something to data in the process with a set field, so I would look for conflicting script triggers on all layouts and fields.


          It's also possible you have stacked scripts, where a script pauses a currently-running script, which automatically resumes when the other script ends, but at an unexpected place in the file.


          Another possibility is that you are capturing data in global variables for these scripted actions, and, if more than one script relies on a $$variable with the same name, they could be conflicting. Or one might be clearing a variable at some point, but the other resuming script is still relying on that same variable name, which is now a null value.


          Also, if the user is performing a force quit instead of a simple application quit/exit that can break the connection to the served files without committing any local changes.

          • 2. Re: Strange error deletes field data

            Thanks for the ideas. That is worth looking in to. I will let you know what I find.

            • 3. Re: Strange error deletes field data

              Do you have auto-deletion of child records turned on in any of your relevant relationship instances?


              - Lyndsay

              • 4. Re: Strange error deletes field data

                No. These relationships do not pass through the relationship graph. Because my solution is exclusive to Filemaker Go, I only use list view even for a single record so that I can keep the header at the top for navigation even while the record is being scrolled. Since you can not filter records in list view with the relationship graph, every layout contains an on layout open script triger that searches the table for the record ID set by the previous layout as a global variable. Also, if it were an auto-deletion of child records it would delete an entire record, and it is only one filed in each record of a found set that is dissapearing.


                Thanks for the idea though.

                • 5. Re: Strange error deletes field data



                  That apears to have been the issue. I made a new layout specifically for this script to pass through and made sure it had no scrpt triggers. I have not had the issue return since. Thanks for the great suggestion!

                  • 6. Re: Strange error deletes field data
                    Stephen Huston

                    Glad that did it for you.


                    Script triggers which run on entering a layout or loading a record can easily come back to bite us when we simply forget somewhere down the road that those wonderful little goodies are there.

                    • When working in FMP12/13, I think its a good idea to write a note in the off-screen grey area of the layout, listing all script triggers for that layout and its fields. I know that coming back to a solution  months or even years later, I need all the help I can get from my former self to remind me what all's going on -- just like fully commenting fields and scripts.
                    • 7. Re: Strange error deletes field data

                      I later encountered the same issue with the same table in another area of my solution. However, this time passing the script through a special layout without script triggers did not resolve the issue. After a whole day of trouble shooting I finally found an answer. I beleave this may be a bug with FileMaker 13 itself because up until I upgraded and had saved the solution with FMPA 13 the script had never had this issue. What I found was that if the soltution is currently in a found set at the time that a new record is created by a script step, that when the new record is then commited that any field data in the previous found set that was keyed in (as apposed to auto enter or chosen from a value list) was erased from the found set records. I was able to solve this by placing a show all script step at the begining of the script that is used to create new records. This clears the found set and the script step creating the new record no longer erases data when it is commited. At the end of this script I then perform a new find to re-establish the found set. I further verified that the issue is limited to found sets and the script step that creates new records by duplicating the steps used by the script with just the toolbar controlls. First creating a found set, then creating a new record and then commiting it. No issue there.

                      • 8. Re: Strange error deletes field data
                        Stephen Huston

                        It sounds like you may simply need a "Commit Record" step at the start of the script to save any edited-but-not-yet-commited data in the found set, before the script moves on to new record creation.

                        • 9. Re: Strange error deletes field data

                          Hmm... I currently have the script start with a Show All step, followed by the create new record, and then a commit record step. The issue is resolved but if you are right, perhaps it is resolved because of the Commit step and not the Show all clearing the found set. I had not thought to start with the commit step because I don't think any records have changed as of that early in the script, so I hadn't tried starting with a commit record step. It might be interesting to to try and see what happens.