1 2 Previous Next 17 Replies Latest reply on Dec 15, 2016 5:34 PM by everyman

    Find & Sorting Issue

    1jdhelle

      Let's say the first time I use find, I find the 33rd record in the database, which is correct.  Now I change to a different tab on my layout and it performs the follow:

       

      Set Variable [$$Tab ; Value: "PA Tab"]

      Go to Layout ["Record Detail Tabs" (Owned_Music_Library) ]

      Go to Object [Object Name: "PA Tab"]

      Enter Find Mode [Restore ; Pause: Off]

      Perform Find [ Restore ]  ----- Action = Find Records Criteria, = Owned_Music_Library::Medium: [= Purple Amberol]

      If [Get (LastError) <> 0

          Show Custom Dialog [ "Message" ; "Purple Amberol = There are no records that match the criteria."]

      Else

          Sort Records [ Restore; With Dialog: off]

          Go to Record/Request/Page [ First ]

      End If

       

      Now the PA Tab displays the 33rd record of the Purple Amberols, rather than the first record.   It's probably a simple solution, but I cannot figure it out.

       

      -----------------------

      Example with screen shots.

       

      Looking at Diamond Disc Tab - Record #5 - this shows the fifth record.

      Diamond Disc Database Record #5 - shows that this is truly record #5 in my database.

       

      Edison Purple - Default to Record #5 - shows that after performing the above script the record appearing is #5 in the database. The above script automatically runs then selecting the Edison Purple tab.

      Edison Purple - Database Record #5 - shows that cylinder number 29040 is the 5th record in the database, instead of the first record.

       

      I can select any of the other tabs and you will always end-up on record #5.

        • 1. Re: Find & Sorting Issue
          SteveMartino

          Your description is a little hard to follow

          Do the tabs contain fields all from the parent layout, or are the tabs representing different layouts?

          Generally it helps to spawn a new window to do a find so you don't ruin the found set, unless you are trying to Constrain or Extend the found set.

          I don't understand why you are setting $$Tab.

          I also dont understand why you Go to Object.  Is that the name of the other tab?

          If all the fields in the tab all are from the same TO, you don't have to switch tabs to do a hard coded find.

          What happens when you watch it with the Script Debugger.

          Seems like a hard-coded find when you should be doing something more dynamic with the standard:

          Set Variable

          Enter Find Mode

          Set Field //field you want to search with the variable set as the criteria

          Perform Find.

           

          But I think maybe the problem is with your sort step

          • 2. Re: Find & Sorting Issue
            everyman

            Couple of things:

             

            1. What are the sort criteria?
            2. It's not clear to me that you need to perform another Find operation just to switch tabs on a layout; just switch to the other tab.
            • 3. Re: Find & Sorting Issue
              David Moyer

              Hi,

              I don't know if this is what is breaking your script, but you don't need both Enter Find Mode and Perform Find set up with Restore Find Requests.  In fact, you don't need Enter Find Mode at all if you use Restore in your Perform Find step.

              Also, in this situation, I'd use Get(FoundCount) > 0 rather than Get(LastError) <> 0.

              • 4. Re: Find & Sorting Issue
                David Moyer

                A couple more things ...

                I'd use Get(FoundCount) > 0 rather than Get(LastError) <> 0

                ... this is because I'm paranoid of hiding a different error in the guise of a zero found count.

                Secondly, I plopped out my version of a "classic" simple scripted find ...

                Hope this helps.

                • 5. Re: Find & Sorting Issue
                  1jdhelle

                  David,

                  I have added screen shots with explanations.  Hopefully it will make more sense. 

                   

                  Get Outlook for iOS

                  • 6. Re: Find & Sorting Issue
                    David Moyer

                    Have you tried removing the Enter Find Mode script step?  That definitely does not need to be there - and it might be breaking your script (because the Restore option is set).

                    • 7. Re: Find & Sorting Issue
                      1jdhelle

                      Removing the Find Mode step did hot help.

                      • 8. Re: Find & Sorting Issue
                        philmodjunk

                        But what would help would be a less confused description of what you have set up here. Like the others, I can't really picture what you are trying to do here and thus suspect that you have some basic misconceptions about how layouts, tab controls and finds work in FileMaker.

                         

                        Just changing tabs on the same layout does not by itself take you to a different record or found set of records. Performing a find on one layout, based on one table occurrence will not change the found set on a different layout if it is based on a different table occurrence. (Table occurrences are the "boxes" found in your relationship graph in Manage Database. You select one in "Show Records From" in layout setup for each layout in your file.)

                         

                        You may need to share an actual copy of your file before we can figure out what you have here and what you need to do.

                        • 9. Re: Find & Sorting Issue
                          1jdhelle

                          I'd be happy to provide the database.  I've deleted many records and reduced the size from 6.3 Gig to 604 MB.  Where would you like me to send it?

                          • 10. Re: Find & Sorting Issue
                            philmodjunk

                            Just click the "use advanced editor" link to top right of the reply box and use it to upload your file to this discussion. (Can't do this via email or from an iPhone.)

                            • 11. Re: Find & Sorting Issue
                              erolst

                              If you save a "compacted copy" (in FileMaker, select File > "Save a Copy As"), then zip that copy (in the Finder / Windows Explorer), the resulting archive file will be considerably smaller.

                               

                              You can post that archive file here in the forum; use the "Advanced Editor" to attach it to a post.

                              • 12. Re: Find & Sorting Issue
                                1jdhelle

                                FYI - Mac, not Windows.  I've got the least amount of information as possible in the database, but it's still 485 MB and it will not upload - says file is too large.

                                • 13. Re: Find & Sorting Issue
                                  David Moyer

                                  you might try to build a super-simple demo from scratch.  You'd come up with a small file to upload here; but you might also figure it out on our own along the way.

                                  • 14. Re: Find & Sorting Issue
                                    1jdhelle

                                    I know I'm asking for a lot of help here, but I'm just stumped.  I'll try to provide a simple example because building a simple database takes me a very long time to create.  I'm no expert at FileMaker.

                                     

                                    I open my database and I default to the apples panel by a find and sort script.

                                     

                                    Open Script -   Show/Hide Toolbars [Hide]

                                                            Perform Script [Set Screen] – determines if an iPad or iMac is being used

                                                            Set Error Capture [On]

                                                            Perform Script [“Apples”]

                                     

                                    Apples Script – Set Variable [$$Tab; Value: “Apple Tab”]

                                                            Go to Layout [ “Record Detail Tabs” (Inventory_Library) ]

                                                            Go to Object [ Object Name: “Apple Tab” ]

                                    Perform Find [Restore] – parameters are Find Records Inventory_Library::Type: [apples]

                                    Perform Sort [ Restore; with dialog: Off]

                                    Go to Record/Request/Page [First]

                                     

                                    Now I am displaying Apple Type 1 and thenI select my “Next” button 3 times.  The next button is setup as – Go to Record/Request/Page [Next].  So now I’m on the third record, Apple Type 3, in the found set.

                                     

                                         First found set of data:

                                         Apple Type 1  

                                         Apple Type 2                                             

                                         Apple Type 3  

                                         Apple Type 4

                                     

                                    Everything is good to this point.

                                     

                                    Now I select the peaches panel in my layout which causes an OnPanelSwitch that runs a script to determine which panel is selected.  Once the panel is determined then a find and sort script is run.

                                     

                                    Determine Panel Script:

                                                Set Variable [$$TabPanel ; Value: Get(TriggerTargetPanel) ]

                                                Set Varable [$$TabName; Value: Get ($$TabPanel; 2) ]

                                                If [$$TabName = [ “Apple Tab”]

                                                            Perform Script [ “Apples”]

                                                Else If [$$TabName = [ “Peaches Tab”]

                                                            Perform Script [ “Peaches”]

                                                Else If [$$TabName = [ “Oranges Tab”]

                                                            Perform Script [“Oranges”]

                                                Else

                                                            Show Customer Dialog [ “Error” ; Determine Tab – No Tab Found” ]

                                                End If

                                     

                                     

                                                Peaches Script:

                                                            Set Variable [ $$Tab; Value “Peaches Tab”]

                                                            Go to Layout [ “Records Detail Tab” ; (Inventory Library) ]

                                    Perform Find [Restore] - parameters are Find Records Inventory Library::Type: [peaches]

                                    Go to Object [ Object Name: “Peaches Tab”]

                                    Sort Records [With Dialog: Off]

                                    Go to Record/Request/Page [First]

                                     

                                    The peaches panel display the first record, but just for a second, then it changes to 3rd record in the new-found set, Peach Type 3. 

                                     

                                    I’m assuming somehow by selecting the “Next” button three times from my first found set is carrying over into my second found set, but I don’t know why.

                                    1 2 Previous Next