3 Replies Latest reply on May 26, 2015 9:58 AM by philmodjunk

    Using Constrain and Extend in a script



      Using Constrain and Extend in a script




      I'm looking to have part of a script which allows the user to do a find then run the script, but just modifying whatever found set exists before the script is called, by adding or removing search criteria - but then return back to the original found set.

      I thought this would be possible by doing something like:

      Constrain search: add '=' in FIELD2

      Extend search: add '*' in FIELD2

      However, it seems to only result in all records.  Yes, FIELD2 is populated on every record, but I want it to only be the original found set (the idea of the above being that FIELD2 will be fully populated once the script gets to that stage).

      I'm probably using the constrain and extend functions wrongly, but the Modify last find is not configurable in a script.

      Can anyone help?

      Many thanks!


        • 1. Re: Using Constrain and Extend in a script

          Putting a lone = in a field--in both a manual and scripted find specifies that the field must be empty in the found set then produced by either perform find, constrain found set or extend found set.

          Here's how you would do that in a script:

          Enter Find Mode [] ---> clear the pause check box
          Set Field [YourTable::Field2 ; "=" ]
          Constrain Found Set []

          Note that all brackets are empty in this example. You could just use:

          Constrain Found Set [Restore]

          But this buries the criteria used in a way that you can't see in the script until you open additional dialogs so the first example produces a script that is much easier to review and maintain. The first example also makes it possible to set up calculations that evaluate to produce the criteria then used in the find and this is not possible for stored criteria.

          For more examples of scripted finds, including some that use Constrain and Extend, see: Scripted Find Examples

          Caulkins Consulting, Home of Adventures In FileMaking

          • 2. Re: Using Constrain and Extend in a script

            Hi Phil,

            Thanks very much for your swift reply.  Apologies if I'm not understanding your answer correctly and/or if I didn't explain my query well enough, but would this allow me to do the following?

            1. Have the user perform any find in any field(s) to get a found set.
            3. Run the script, which constrains that found set to check that (within that found set) FIELD2 is not blank.
            5. Extends or removes the constrain criteria (assuming no blank FIELD2's exist) and returns back to the original found set.

            Thanks again,


            • 3. Re: Using Constrain and Extend in a script

              It will do 2. It will not do 3. You'd have to either keep a copy of the original find in a separate window or perform the find with the original criteria again.