"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.
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 "*".
Yeah, hmm. I'd rather just stay on the current layout.
create a fake self-relationship like pk ≠ pk, set error capture on, go to related records through that relationship using current layout ?
Set Error Capture [On]
Constrain Found Set [Restore] <--- inside here, pk = -1
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.
Hmm, this might work. I wonder if Constrain Found Set is faster than Omit.
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 ""...
played with it all a bit and taking note of times.
This is my best offer:
Allow User Abort [Off]
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.
Creative. Let me try this for a bit…
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…
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
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...
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.