1 2 Previous Next 17 Replies Latest reply on Dec 15, 2016 9:44 AM by wendy

    FM13>FM15: Script to delete portal row suddenly deletes master record in FM15

    wendy

      We went live last night from FMS13 to FMS15 on an iMac running El Capitan and the latest version of FMS. PC clients were upgraded to FM15. Mac clients were left at FM13.0.9 until we upgrade the Mac OS from Mavericks.

       

      This is a legacy database with 21 files and ...inherited programming. The script with the problem was created in 2009, at a time when the database version was FM8. The script is initiated by a button in a portal row to delete that join record/row. The button apparently "loses" context and instead deletes the master record. (I did preliminary testing but if it occurred there, I missed it.)

       

      I temporarily reverted the PC user who run this process from FM15 back to FM13.0.9. It works fine in FM13 (accessing records now served by FMS15).

       

      But I'm having trouble getting my head around this programming/design and am not sure what to do to solve the problem in FM15. (And am hoping it won't show up elsewhere!) Can anyone help?

       

      The troubled script and details:

       

      Allow User Abort [Off]

      Set Error Capture [Off]

      If [IsEmpty (DD_PutUP_JOIN::DieDetail_DieNumber_fk)]

         Show Customer Dialog ["Selected Row Is Empty";

         "Please select a row that contains a die number."]

      Else

        Show Customer Dialog ["ALERT!";

           "Are you sure you want to DELETE the die  \"" &

           DD_PutUp_JOIN::DieDetail_DieNumber_fk &

           "\"  from this PutUP?"                               (Buttons are Cancel with Commit Data checked, and "DELETE".)

        If [Get {LastMessageChoice) = 1]

           Exit Script [Text Result: ]

        End If

      End If

      Delete Record/Request (With dialog:Off]

      -----------

      The user creates the master PutUp records, then uses this layout/portal to both add and remove die records from the PutUp record. Similar in function to an Order record with line items. Scripts to add dies to the portal are working.

      Script was/is set to run with full access privileges. Layout Context is table DD_PutUp. Portal shows related records from DD_PutUp_Join; this is a join table between the "DieDetail" table and the DD_PutUp table. The portal setup allows deletion of portal records.

        • 1. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
          erolst

          It seems there are some Exit Script[ ]s missing in the script:

           

          After the warning on an empty die, the script should exit; and it should exit if in the other branch the user chooses Cancel:

           

          ...

              Show Customer Dialog [ ... ; Buttons are Cancel with Commit Data checked, and "DELETE".)

              If [Get {LastMessageChoice) = 1]

                Exit Script

              End If

            End If

            Delete Record

           

          As it stands, the program flow reaches the Delete Record lines, regardless of the Die status at the beginning and any user choice in the second dialog.

           

          EDIT: and yes, you should use Delete Portal Row ...

          1 of 1 people found this helpful
          • 2. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
            flukey

            You should use Delete Portal Row instead of Delete Record.

             

            Flukey

            1 of 1 people found this helpful
            • 3. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
              wendy

              My apologies, my original post was incorrect. (Just a bit flustered right now.) The script does include an "Exit Script" step. I've edited my original post.

              • 4. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                philmodjunk

                And this script looks dangerous to me.

                 

                Delete Portal Row is an option that won't delete the master record if the focus goes wrong (and this can easily happen due to layout modifications made at a later date).

                 

                You could also "disconnect" the record by clearing a match field so that it drops out of the portal and then, a "housekeeping" script can run at a later date to find and delete records where the field is empty.

                 

                Or you can open an "off screen" window, find the related record in it on a layout based on the portal's table and delete it there.

                 

                All safer options than delete record as scripted here where the focus determines whether child or parent record is deleted.

                1 of 1 people found this helpful
                • 5. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                  wendy

                  flukey, thank you that would make sense and I will try it... but isn't it odd that the original programmer used "Delete Record/Request" instead, and that the script works as is in FM13 to delete the row, but in FM15 deletes the master record? Does the context/focus differ in FM15?

                  • 6. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                    philmodjunk

                    It shouldn't have, but a change in focus is not hard to have happen. Determining how in this case would require careful, repeated testing using the script debugger so that you can watch for the focus. The script, for example, might trip a script trigger and a trigger controlled step might interfere and change the focus.

                     

                    I'd also check to make sure that the button in the portal row was till part of the portal by moving the portal to see if the button moved with it.

                     

                    Or layout corruption to the layout might be resulting in a loss of focus on the portal row.

                    1 of 1 people found this helpful
                    • 7. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                      wendy

                      The button does move with the portal.

                      I don't see any script triggers on this layout.

                       

                      Changing the step to Delete Portal Row fixed the issue.  I'm guessing that the previous programmer copied this script from earlier work, and since Delete Record/Request has worked until now, it was left as is.

                       

                      philmodjunk, this script looked dangerous to me also. This database is full of older scripts that work within portal rows; if I ever am allowed the time to overhaul it, this type of programming will go. The most unnerving to me is that something like this changed between FM13 and FM15... (No, I take that back. The most frightening is that word you used: "corruption". This database has been in existence and built upon since FM5 or even earlier.)

                       

                      I'm still new at using the FM15 Script Workspace. I have used the debugger in previous versions. Would you be able to briefly explain how to use it to check the focus? There isn't anything changing visually on the layout screen when I step through the script, nor do I see any clues in the debugger itself. (The custom dialog DOES indicate the correct row--it lists the die number expected to be deleted.)

                       

                      Thanks to both of you, philmodjunk and flukey.

                      • 8. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                        flukey

                        I am not sure but suspect that the focus is changing because of the dialog screen that you are showing to confirm the deletion.   Remember that the Delete Record step will delete the current record,  but it will delete the portal record IF the current focus is the portal.  Well, once you pop up the dialog box you have removed the focus from the portal and thus the main record is now the focus, thus the delete step is operating on the main record.

                        1 of 1 people found this helpful
                        • 9. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                          wendy

                          Interesting experiment, flukey... I disabled the dialogues and simply had the button execute "Delete Record/Request". It still deletes the master record in FM15, but correctly deletes just the portal row in FM13.

                           

                          That makes it seem like the portal row never gets focus at all... yet Delete Portal Row DOES work.

                          • 10. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                            philmodjunk

                            That's very weird since the portal row MUST have the focus in order to delete a portal record.

                            • 11. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                              wendy

                              Very weird indeed.

                               

                              Copy a backup from last night.

                              Open in FileMaker 13.

                              Delete ALL steps in the script except the final Delete Record Request.

                              Run the script using the portal button.

                              The portal row is deleted.

                               

                              Make a second fresh copy of the same backup.

                              Open in FileMaker 15.

                              Delete ALL steps in the script except the final Delete Record Request.

                              Run the script using the portal button.

                              The entire master record is deleted.

                               

                              I've already found another portal button script that shows the same changed behavior in FM15.

                               

                              It does appear to be some sort of corruption introduced by the conversion to FM15. I suppose all I can do is fix this script to use Delete Portal Row, and hope such corruption isn't widespread.

                              • 12. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                                Malcolm

                                If you look at the behaviour of the scripts in the attached file you can see that the "Delete Portal Row" script step has to be within a portal to work.

                                 

                                The Delete Record script step is "Portal Aware" to a certain extent. If you have a button in a portal that is using the Delete Record step that does not change the context then it will delete the portal row.

                                 

                                However, in the example file, we can see that once you have changed context to the parent record, you can return to the portal row, but the delete record script step is performed in the context of the parent record.

                                • 13. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                                  wendy

                                  Thank you, I will take a look at your file.

                                   

                                  The problem I have is:

                                   

                                  - a portal button using the Delete Record step deleted the portal row as expected in FM13, but when the file is opened in FileMaker 15, with no other changes, the same button/script suddenly starts deleting the master record instead. I have found three scripts now (in two separate database files) where this change has occurred with FM15.

                                   

                                  - Troubleshooting shows that if the script used by the portal row button contains ONLY the Delete Record step, and has no other steps that might change context, the change in behavior between FM13 and FM15 still occurs.

                                  • 14. Re: FM13>FM15: Script to delete portal row suddenly deletes master record in FM15
                                    philmodjunk

                                    Your answer is making an assumption that is not necessarily the case.

                                     

                                    It does happen from time to time that a file works without observable issue in one version or on one platform and then shows signs of a damaged file when opened in a new version or on a different operating system. This appears to happen in cases where the problem did not affect the file's function until the newer/different code interacts with the damaged file.

                                     

                                    So the fact that it worked perfectly when used with the older version of FileMaker does not mean that the file is not damaged.

                                     

                                    Regardless, I would never use delete record to delete a record from a portal row, that's right up there in my mental list of "brittle database features to be avoided" as it could break quite easily in the future without any file corruption taking place.

                                    1 2 Previous Next