6 Replies Latest reply on Jul 16, 2009 4:26 PM by philmodjunk

    Go To Related Record: Does not switch to layout specified if no records found

    slemson

      Summary

      Go To Related Record: Does not switch to layout specified if no records found

      Description of the issue

      I just discovered something that caused me a huge problem. FileMaker Product(s) involvedFMPro 10 Mac is all I've tried this on Operating System(s) involvedMac OS X 10.5.7, perhaps others.  Untested.Detailed description of the issueGo To Related Records script step does not switch to the specified layout if no related records exist. Exact steps to reproduce the issue1. Create two tables (Table A and Table B) and relate one to the other.2. Create a portal on Table A's layout with records from Table B but leave Table B empty.3. Create some records in Table A (again, leave Table B empty for now)4. Create a script with a "Go To Related Records" step that goes to Table B using Table B's Layout, (check the box that says "Show only related records")5. For fun (not really) put a "Delete All Records" script step following the "Go To Related Records" script step. (Essentially, I want to clear out a portal for a given Table A record)  Expected ResultI'd expect that regardless of whether or not there are records in Table B that are related to A, it will take me to Layout B, then delete all records.  If there are no records, then obviously, nothing will be deleted but the script should still bring me to the related layout I specified. Actual ResultIn actuality, when there are no records in Table B related to the record displayed in A, it never goes to that layout, and the "Delete All Records" step deletes all records in Table A instead! Exact text of any error message(s) that appearedNone Any additional configuration information/troubleshooting that is relevant to the issueNone Any workarounds that you have foundSet up an If/Then that checks for related records before executing the "Go to Related Records" script step. 

        • 1. Re: Go To Related Record: Does not switch to layout specified if no records found
          mrvodka
            

          I forgot what version this changed. Perhaps 8.

           

          Anyway, you have to error trap using an error capture or you can check first to see of related records exist first.

           

          All my GTRR script steps always check to see if there are related records first.

           

          If [ not IsEmpty ( pkChildID ) ]

          Go to Related Records [Child]

          Else

          Show Custom Dialog [ "No Related Records" ]

          End If

          • 2. Re: Go To Related Record: Does not switch to layout specified if no records found
            slemson
              

            Thank you for the reply.  I'm disappointed in the behavior.  Especially in the 7+ paradigm of it being so important what window/layout is in front before operating on records.  I think it would be easy for Filemaker to make the behavior always go to the layout if specified in the "Go To Related Records" script step with a found set of zero records.  At least then, the steps following would operate as intended.

             

            I can't think of a reason why this behavior would be the way it is except perhaps to save a millisecond of speed but to me, the trade off of not knowing for certain whether I'm on the right layout isn't worth the speed gain. 

            • 3. Re: Go To Related Record: Does not switch to layout specified if no records found
              mrvodka
                 Inconvenient yes. But I think logically it makes sense. Because it produces an error, the script step fails. Since it fails, it continues onto the next script step. Going to the layout was a part of the GTRR step.
              • 4. Re: Go To Related Record: Does not switch to layout specified if no records found
                PeterWagemans
                  

                I think this already changed in 7. It caused a major problem in migrations from 6, and today I still have doubts on this decision that FileMaker made in its infinite wisdom. By the way, it's better to check the related key for emptiness, instead of the local key...:-)

                 

                Suppose you GTR based on the current set of records instead of the current record, if one or more records in your current set has no related record(s), FileMaker wil jump to the related record set, but still raises LastError. And last time I looked, it was not different from the error raised if there is no related record.

                Which makes it pretty unuseable for a developer.

                 

                Suppose  - with this last example - you want to jump to a related record set based on your current layout... then you're really in trouble. You have to use another layout for the GTR, or you will not be able to check things properly.

                 

                Should FileMaker change this behaviour back to the way it was? Please NO! Or we will be spending hours again debugging solutions.

                Still, this is frustrating stuff. And that's the nice way of putting it.

                 

                • 5. Re: Go To Related Record: Does not switch to layout specified if no records found
                  mrvodka
                    

                  clarifix wrote:

                  By the way, it's better to check the related key for emptiness, instead of the local key...:-)

                   


                   Who said to check the Parent key?

                   

                   

                   


                  clarifix wrote:

                   

                  Suppose you GTR based on the current set of records instead of the current record, if one or more records in your current set has no related record(s), FileMaker wil jump to the related record set, but still raises LastError. And last time I looked, it was not different from the error raised if there is no related record.

                  Which makes it pretty unuseable for a developer.


                   

                  Not quite... When using a GTRR with matching set, if none of the parent records have matching children records, then it should result in a 401 error. However, if the first parent record does not have related records but some of the other parent records do, then it will result in a 101 error.



                  • 6. Re: Go To Related Record: Does not switch to layout specified if no records found
                    philmodjunk
                      

                    I agree that discovering this completely undocumented "feature" was a major unpleasant surprise for me as well.

                     

                    What's even more inconsistent is that if you select "current layout" and that layout is valid for the relationship (such as a self join), it works just fine and produces an empty found set.

                     

                    With all due respect to differing opinions here, I don't think a script should ever silently move on to the next step if an error condition occurred during execution of the previous step. Such "silent failure" wastes a lot of developer time and risks doing major damage to the data in a manner that may not even be noticed by the user until much later.

                     

                    Unfortunately for filemaker, a number of such "silent failures" can occur with different script steps and most are undocumented in the online help which can set up catastrophic pitfalls for the novice developer.