AnsweredAssumed Answered

Checking for blank search fields

Question asked by sreese on Nov 18, 2015
Latest reply on Nov 19, 2015 by sreese

Good Morning FileMaker community,


I am currently working through our solution here at work and have discovered a disturbing lack of checking that search criteria has actually been entered. It isn't a huge deal when you're talking a few hundred thousand records, but we have tables with record counts in excess of 7 million records, and looping through that many records can take quite some time.


The original developer of the solution used the 1 script to rule them all premise, which makes checking for fields time consuming. I have to figure out where the best place to put them is.


What I would normally do is something like this:


if [ isEmpty ( list ( field1 ; field 2 ; field3; ... ; fieldLast ))]
     Show Custom Dialog : "No Search information entered"
     Halt Script
End If


After running through script debugger step by step to figure out how exactly the scripts were processed I figured out that FileMaker returns an error on no search criteria entered with a code of 400.


So now I find myself doing something along the lines of the following:

If [ Get ( LastError) = 400) ]
     # Check for search criteria
     Go To Layout [ Original Layout ]
     Show Custom Dialog [ "Error" ; "Please enter search criteria and try again."]
     Halt Script
Else If [ Get ( LastError) = 401) ]
     # Check for results
     Go To Layout [ Original Layout ]
     Show Custom Dialog [ "Error" ; "Your search did not return any results, please try again with different criteria."]
     Halt Script
Else If [ Get ( FoundCount ) < $$findWarningCount]
     # The search returned a lot of results, confirm they want to continue processing the script
     Show Custom Dialog [ "Warning: Result Count" ;
          "Your search returned a lot of results and may take several minutes to process. Would you like to continue? "]
     If [ Get ( LastMessageChoice ) = 2 ]
          Go To Layout [ Original Layout ]
          Halt Script
     End If
End If

Continue performing the script afterwords.


What methods do you use, and where can I find some improvement to my methods? Will this secondary method be substantially slower than the first? All I am noticing is a split second right now because of extra processing steps.