3 Replies Latest reply on Nov 19, 2015 4:28 AM by sreese

    Checking for blank search fields

    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.

       

      Thanks!

       

      Scott

        • 1. Re: Checking for blank search fields
          DavidJondreau

          The second solution seems reasonable. It does more than the first. The first won't catch no records found or large found sets.

           

          I think you've got the last Else If[] backwards. > not <.

           

          DJ

          • 2. Re: Checking for blank search fields
            siplus

            sreese wrote:

             

            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.


            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.

             

            Thanks!

             

            Scott

             

            We simply educate our users, telling them that "Finding" usually implies entering somewhere what to look for.

             

            In the meantime most of them slimed out from under their rocks and are using some kind of portable device which does not treat them well if they search for nothing. We are more tolerant, but not too tolerant.

            • 3. Re: Checking for blank search fields
              sreese

              DavidJondreau wrote:

               

              I think you've got the last Else If[] backwards. > not <.

               

              I do! Good catch!