1 2 Previous Next 15 Replies Latest reply on Mar 26, 2015 11:22 AM by johnnyb

    How to clear or reset the found set?

    johnnyb

      I want to reset the found set to nothing, as if a find had not yet been performed, from a script. It seems like something that should be obvious and simple to do. Is there a trick for this?

       

      I could do a Perform Find and omit "*", but I feel like that has me performing a search, which seems like a waste of resources. I really want to just have the found set get dumped and the query cleared out, which seems like it should be a very efficient thing to do.

       

      Switching from Browse mode to Find mode and back doesn't seem to do it.

       

      There's the Show All Records script step. But there isn't a Show None Records counterpart…

       

      I'm a bit puzzled, and not sure what to look for.

       

      Thanks!

        • 1. Re: How to clear or reset the found set?
          siplus

          "Show all records" followed by "show omitted only"?

           

          NB: For efficiency these 2 script steps should be performed after a "go to Layout" script step that goes to an empty layout, then you go to the original layout. That's because you don't want to send the server a message of "gimme all the records, I need to show them" and being taken seriously.

          • 2. Re: How to clear or reset the found set?
            johnnyb

            Is there no way to avoid showing all records, though? Loading the entire data set just to hide it seems even less efficient than omitting "*".

            • 3. Re: How to clear or reset the found set?
              johnnyb

              Yeah, hmm. I'd rather just stay on the current layout.

              • 4. Re: How to clear or reset the found set?
                siplus

                create a fake self-relationship like pk ≠ pk, set error capture on, go to related records through that relationship using current layout ?

                • 5. Re: How to clear or reset the found set?
                  siplus

                  or

                   

                   

                  Set Error Capture [On]

                  Constrain Found Set [Restore] <--- inside here, pk = -1

                  • 6. Re: How to clear or reset the found set?
                    johnnyb

                    I guess I should refresh to get your final edits before replying so that I don't come off looking like I didn't read your post.

                     

                    What I'm looking for is a technique to dump the results on-the-fly. Two scenarios:

                     

                    In one, I want to land on a "search" page with an empty input field and no results showing. Every time the user hits this page, I want them to be starting fresh. As it is, they always see the results of their previous search. That's desirable in a lot of cases, but not when I'm offering to let them start a "New Search." In this scenario, I want to preserve the found set sometimes, and clear it out sometimes, depending on what the user wants to do.

                     

                    In another, I want Quick Find to show zero results if it comes up with nothing. I'm using Quick Find for pseudo-live results; if there are zero matching records, the results actually just freeze on the last query that succeeded, which is confusing. What I'd rather have it do is show "zero results" — which serves as a pretty good indicator that the Quick Find didn't find anything. So I'm trying to do something like If FoundCount = 0 then <clear out the results>.

                     

                    In both of these cases, I need to stay on the same layout and avoid the overhead of showing and then hiding all records in order for everything to stay snappy.

                    • 7. Re: How to clear or reset the found set?
                      johnnyb

                      Hmm, this might work. I wonder if Constrain Found Set is faster than Omit.

                      • 8. Re: How to clear or reset the found set?
                        siplus

                        I feel your pain - on nothing found QuickFind will leave the found set as it was and your only option is to look at Get(LastError) which will hold value 401.

                         

                        In our solution we display search results in a portal based upon a relationship, a global holding pk's with the real pk's. On entering search we set the global to "", on keypress I do a QF with the global's content and if error is 401 I reset the global to ""...

                        • 9. Re: How to clear or reset the found set?
                          siplus

                          played with it all a bit and taking note of times.

                           

                           

                          This is my best offer:

                           

                           

                          Allow User Abort [Off]

                          Freeze Window

                          Go to Record/Request/Page [First]

                          Set Variable [$totalRecords; Value:Get ( FoundCount )]

                          Omit Multiple Records [No dialog; $totalRecords]

                           

                           

                          417 miliseconds on a table with 147622 records in which the initial found set was all records.

                          • 10. Re: How to clear or reset the found set?
                            johnnyb

                            Creative. Let me try this for a bit…

                            • 11. Re: How to clear or reset the found set?
                              johnnyb

                              My findings:

                               

                              Perform Find where PK = (-1): ~420ms

                              Show All + Show Omitted Only: ~30ms

                              Omit Multiple [ Get ( FoundCount ) ]: ~10ms

                               

                              I still feel like there should be a method that takes only 0ms, but for want of that…

                               

                              Well done.

                              • 12. Re: How to clear or reset the found set?
                                siplus

                                Good side effect, the omit multiple method does not destroy your (unsuccessful) find request(s) !

                                 

                                Thanks for loving Get ( CurrentTimeUTCMilliseconds ) at least as much as I adore it

                                • 13. Re: How to clear or reset the found set?

                                  Simple:

                                  Omit multiple records (get(foundcount))

                                   

                                  It took a long time for FileMaker to let us put the calc in a script rather than a fixed number and it works like magic... 

                                  • 14. Re: How to clear or reset the found set?
                                    justinc

                                    JohnyB,

                                         Looks like you already did your testing and found the fastest solution.  I hadn't heard about the 'omit multiple (get(foundcount))' option before and that seems like a good possibility.

                                     

                                    One caveat to the 'show all'/'show omitted' is that this isn't 100% guarantee that this will yield zero results.  There is a split second in there where it is conceivable that another new record could be created after you 'showed all'.  Then you would be showing one record.  Highly unlikely, but still something to consider.  Also, there shouldn't be too much of a performance impact in terms showing all the records; FM doesn't actually download ALL the records when you do that, but only 50 or so.  And depending on how you got to the layout in the first place, those records are most likely already in your local cache, and so there wouldn't be anything to download (if this is a server solution).

                                     

                                    The method to more ensure a zero found set (apart from the 'omit multiple' idea) is to do a find for something that doesn't (or couldn't ever) exist in the system, e.g. the PK = -1 option noted above.  But, as you demonstrated, this takes a bit more time.

                                     

                                    I'm really liking the 'omit multiple' solution all the way around; seems to guarantee the zero records and also seems to take the least amount of time.

                                     

                                    --  Justin

                                    1 2 Previous Next