7 Replies Latest reply on Feb 8, 2013 10:25 AM by BenDouglas

    Mysterious unrelated table error



      Mysterious unrelated table error


           I have an OpenDatabase script that when I first open the database, it causes the unrelated table error:

           "This operation could not be completed because the target is not part of a related table"

           The script does the following:


           Set Window Title
           Move/Resize Window
           Show/Hide Toolbars
           Enter Browse Mode
      Go to Layout ["Dashboard" (Dashboard)]
           Set Field [Dashboard::z_DashboardViewTimeSpanFrom; Get ( CurrentDate ) - Time ( 24*30 ; 0 ; 0 )]
           Set Field [Dashboard::z_DashboardViewTimeSpanFrom; Get ( CurrentDate )]
           Set Field [Dashboard::z_TextActive; "Active"]
           Now using an If [0] statement I narrowed it down to the "Go to Layout ["Dashboard" (Dashboard)]" step that's causing the problem, but I can't understand why. Shouldn't the Go to Layout action not care about related tables?
           I checked for any script triggers that may be erroneously loading and couldn't find any...
           To add to the mystery, if I just try to run the script while the database is already open, no error. So it's something specifically in the database startup that's causing the problem...
           So what could be happening? What can I look for?

        • 1. Re: Mysterious unrelated table error

               Also yes, the z_DashboardViewTimeSpanFrom, z_DashboardViewTimeSpanTo (mistyped that in the original post), and z_TextActive variables are all Global, I'm sure of that

          • 2. Re: Mysterious unrelated table error

                 I suspect that a script trigger is performing yet another script that then produces the error message.

                 What layout do you see if the Go TO Layout step is not performed?

                 Check that layout for script triggers, especially an OnLayoutExit trigger.

                 Your script also might be tripping an OnLayoutEnter or other script trigger on the Dashboard layout.

                 Such changes in layouts might trip a number of different script triggers when you open the file, but if you run the script with the dashboard layout already selected as the current layout, they won't.

            • 3. Re: Mysterious unrelated table error

                   It opens the "Orders List" layout, which I assume is because that was the last window opened on the host computer.

                   There is no OnLayoutExit script trigger for that layout, nor is there an OnLayoutEnter script trigger for the Dashboard

                   BUT there is an OnLayoutEnter script for the Orders List layout. It runs "FilterOpenClosed" which is:

                   Show All Records
                   If [z_Search::z_OrderList_ShowOpen = "Open"]
                   Constrain Found Set [Restore]
                   Else If [z_Search::z_OrderList_ShowOpen = "Closed"]
                   Constrain Found Set [Restore]
                   End If
                   Sort Records [Restore; No dialog]

                   All the values used there are Global too, or part of the Orders table.

                   z_Search and Database are both instances of a table called z_Resources, which I keep mostly variables and things to run the backend of the system... maybe they conflict?

              • 4. Re: Mysterious unrelated table error

                     Also if I run the OpenDatabase script from the Orders List layout while the database is already open it works with no error.

                     I went back to the OpenDatabase script and added a Go to Layout ["Orders List"; Orders] before the Go to Dashboard action and it still worked without errors.

                • 5. Re: Mysterious unrelated table error

                       Please note that OnLayoutExit and OnLayoutEnter are the most likely suspects, but other scripttriggers may be tripped by a change in layout.


                            maybe they conflict?

                       They won't conflict but your table occurrence context--as determined by the current layout, may make one or both of them inaccessible to steps in your script at the moment that they execute.

                       If you had FileMaker Advanced, I'd suggest the following:

                       Launch filemaker advanced without opening the file.

                       Enable the script debugger.

                       Open the file and step through the script steps one step at a time until the error dialog appears.

                  • 6. Re: Mysterious unrelated table error

                         Sadly we don't have Advanced :/

                         But you did help me narrow it down to that OnLayoutEnter script! When I disabled it on the Orders List the error went away at startup. I'll investigate further later... Might just ignore it and just add a script to go to a safer Layout before switching to the Dashboard.

                    • 7. Re: Mysterious unrelated table error

                           You know what I think it might be...

                           The OnFirstWindowOpen script trigger in the File Options probably takes precedence over the layout's OnLayoutEnter trigger, but it still queues the OnLayoutEnter script to run after the OnFirstWindowOpen script, even if it goes to a different layout.

                           That's my guess. I've got to head off to another client now, but thanks for the help Phil!