5 Replies Latest reply on Dec 29, 2010 12:58 PM by philmodjunk

    Help me to script for find mode

    Rajkumar

      Title

      Help me to script for find mode

      Post

      Hi all,

      In find mode, when we search for a field/s, and go for find, then in case it matches the string, then it displays the resulted record, but when no string of that field matches, then filemaker displays a dialog message, for either to modify find or cancel, and when we choose "cancel", then it goes back to "browse mode" and shows non-omitted record only.

      My problem is, i m unable to do the same through the script, so pls tell me anyone, how to fix this problem.

        • 1. Re: Help me to script for find mode
          ninja

          Howdy,

          Step one, set ErrorCapture (On) before your Perform Find step...that will suppress the dialog.

          Step two, perform and If - EndIf based on the found number of records:
          If (Get (FoundCount) = 0)
              Do this thing...
          EndIf

          Check out the ErrorCapture and Get(FoundCount) functions in your help menus...they appear to be what you are looking for.

          HTH...

          • 2. Re: Help me to script for find mode
            Rajkumar

            Hi, thanks for reply.......but..........

            As i mentioned in my question, by doing this, , if u will cancel perform finding (when error dialog appears) when no matches occur, then it will omit all the previous results, i.e. 0 record will be retrieved.

            while making use of filemaker find button, even if no matches occur, and pressing the cancel button in the error message dialog, you will get the last non-omitted record.

            so how this can be done, any idea.....(in case no matches occur, then i want previous non-omitted records, when cancel button is pressed)

            pls reply.

            • 3. Re: Help me to script for find mode
              philmodjunk

              Use new window to perform the search in a new window. Since the search is perfomed in a new window, closing this window returns you to your original window and your original found set if left unchanged.

              Or define a second table occurrence to the same table and create a layout for displaying your search results that refers to this new table occurrence. Your script would then switch to this layout and perform the find. If no records are found, the script just switches back to your original layout where it's found set, sort order and current record remain, unmodified by the search.

              • 4. Re: Help me to script for find mode
                Rajkumar

                Hey,

                The problem for making a search in a new window is that, suppose u do have a larger number of records, and u want to omit those records which doesn't match ur criteria (because u don't need it now, but even u can't delete it), then for this case, it'll not help at all.

                And problem in defining the occurence of new table may cost a lot, as it'll work well when number of records are less, but for the case of larger number of records, it'll we costly as it requires double storage space.

                • 5. Re: Help me to script for find mode
                  philmodjunk

                  And problem in defining the occurence of new table may cost a lot, as it'll work well when number of records are less, but for the case of larger number of records, it'll we costly as it requires double storage space.

                  That is not the case. A table occurrence is not an actual table. It's simply a box on your relationship graph that (in this case) points to the same data source table as the table occurrence on which your current layout is based. This technique exploits a key detail about FileMaker Table Occurrences: For a given window, each Table Occurrence box in Manage | Database | Relationships maintains a separate, current record, found set and sort order. If you are interested, see this thread on table occurrences in FileMaker: Tutorial: What are Table Occurrences?

                  With either method, you can perform your find twice. Peform it once on the other layout or in the other window. If records are found, repeat the find on your original layout. If none are found, close the window or return to your layout from the other layout and your original found set remains unchanged.

                  Another option would be to capture the serial numbers in a variable or global field (if you have defined a serial number field for your table), of all the records in your found set prior to performing the find. If the find produces zero records, you can use the list of serial numbers with either Go To Related Record or another find to put back the records originally present. (Restoring the proper sort order may be difficult to do, however, if sort orders are specified via the records menu instead of a script.)