4 Replies Latest reply on Jun 27, 2013 7:24 AM by hferrell

    Halt script if no records found

    hferrell

      Title

      Halt script if no records found

      Post

           I have a Button Setup that Triggers a defined scripted Find Search.  At the end of the script it calls for a change in layout and directs to a Tab Panel for the results.  I do not want to be directed to a tab panel unless there are records found.  If the find has no returns, I would like for the message “No records match this find criteria” to appear.  I do not want to be directed away from my present layout. How do I halt the script if no returns appear before running the last line in the script? 

        • 1. Re: Halt script if no records found
          philmodjunk

               Set Error Capture [on]
               Perform Find
               If [ Get (FoundCount ) // records where found ]
                  Go to Layout, etc...
               Else
                  Show Custom Dialog [ "No records were found..."]
               End IF

               Sometimes, I use Else IF and have three possible outcomes: if one record is found go to a form view "detail layout", if multiple records are found go to a list view layout where a button can select one for the detail layout or show an error message when no records are found.

          • 2. Re: Halt script if no records found
            hferrell

                 Trying but don't understand what this line is doing or how it should read:

                 If [ Get (FoundCount ) // records where found ]

                 The "//" is confussing to me.

                  
                  

            • 3. Re: Halt script if no records found
              philmodjunk

                   You can enter it exactly has i typed it.

                   // is a "comment" operator that causes FileMaker to ignore all text to the right of it in a calculation. The text to the right is a coment helping document the intended function of that script step.

                   You can also just use:

                   If [ get ( FoundCount ) ]

                   or if you find it more clear:

                   If [ Get ( FoundCount ) > 0 ]

              • 4. Re: Halt script if no records found
                hferrell

                     Perfect! 

                     Thanks,

                     Hal