9 Replies Latest reply on Jul 14, 2017 9:30 AM by marksealey

    Scripting Extend Found Set


      I have a working example based on this thread (where I populate the fields on a Layout with globals as advised) and where the single action it to Submit a search.


      At the moment my only Find script enters Find mode and performs (successfully) a simple find.


      I need to refine the users' ability to refine the search - starting with Extending the found set.


      Would I be correct to add a second button to the Layout (the first/only button thus far simply runs that script) which uses the script step, 'Extend Found Set'?


      If so, am I correct that the 'Restore' parameter should be present?


      If so, how do I add 'Restore' as a parameter between [square brackets], please?


      Is that all I need to do; or should I, for example, include a sub script somehow/somewhere in the main Find script?


      Can I assume that FMP (14) remembers the found set which I am seeking to extend (and potentially, eventually, to constrain) and will work on that subset of data in any given Layout?


      Can I even keep using the same Layout which I have built for the first (existing) Find operation?



        • 1. Re: Scripting Extend Found Set

          If your criteria is in globals, do not use Restore.



          Enter find mode

          Set fields to values from globals

          Extend found set


          It's essentially the same scripted find from globals method, but with Extend Found set instead of Perform Find.

          • 2. Re: Scripting Extend Found Set

            Thanks, Phil!


            The (first) search script is attached (as graphic).


            Shall I just replicate it in the Extended search - except at line 31, where I use the Step Extend Found Set?


            Will that preserve the previous Found set?FullSearch.jpeg

            • 3. Re: Scripting Extend Found Set

              a) Yes

              b) Well no, it will extend that found set so that will definitely change the found set. It will, however add additional records that match the newly specified criteria to it if any match the criteria specified in those global fields and I think that's what you really meant by that question.


              Keep in mind that this scripted technique using global fields closely mirrors how you do a manual find. You can think of the set field steps that copy from the global fields as the equivalent of manually typing in criteria while in find mode. So you can test these ideas with a manual find and have pretty good confidence that you can replicate it with the above method.


              You may find the first part of this discussion helpful:

              Scripted Find Examples

              • 4. Re: Scripting Extend Found Set

                That's extremely helpful, Phil, thanks; it really does answer my question. I'll give it a try.



                • 5. Re: Scripting Extend Found Set

                  Attached (a screen grab of) the Extend Found set script.


                  But I'm not getting OR results when I call this script from a button on the same Layout. It's as if they are ANDed.


                  I suspect something in the flow of the scripts. Or am I missing a Step, please?


                  Just to be clear, the Layout in question has two buttons. One ("Add criteria") calls the Extend script (screen grab in this post); the other ("Submit") calls the Full Search script (earlier screen grab).


                  Thanks for any ideas!



                  • 6. Re: Scripting Extend Found Set

                    I think that you may be misunderstanding "extend found set".


                    This option is like performing a find for the criteria specified, but then you add any records found by this find to the found set that was present before you performed this "extend" type of find.


                    So it would be an "and" find for all the criteria currently present in all of the above global fields, but then that find is merged with the found set present before your did this.

                    • 7. Re: Scripting Extend Found Set

                      Yes, Phil; thanks, I may - and I am probably only half explaining what I want to do. Sorry :-)


                      I do want to add two sets of data together (I hope I understand that correctly as an OR) - by extending the first set of records to include the second set of records. That's what I mean by OR: either one set or the other, which effectively extends (augments) the number of records found.




                      Might this be confusing the issue: any value in each and every field except the five Category fields has to be ANDed (ultimately) with the ORed totality of values from those five Category fields, which are Checkbox sets?


                      All values for all checkbox sets need to be ORed with one another and the result ORed with the ANDs of all the other fields!


                      So perhaps my scripts are trying to combine operations which need to be combined in some other way?


                      Your help much appreciated!

                      • 8. Re: Scripting Extend Found Set

                        So if two category check boxes are selected in the same global field, you need to find all records matching the other specified criteria that are in either of the two categories?


                        Can't just set a field to the value of the global field if that's the case, You have to extract each of the different selected check box values and specify them either in different find requests or extend the found set with each in turn.


                        Please refer to the link that I recommended earlier for examples of how to perform a find when you need to do this type of thing.

                        • 9. Re: Scripting Extend Found Set



                          Yes - if two (or more) Categories' check boxes are selected in the same field, the result needs to OR them.


                          The result also needs to OR those results with the values of all the checkboxes in other Categories' checkboxes.


                          To that Found set I need to AND records matching any of the other fields. For example:


                          If three categories are checked in one Checkbox set and one in another checkbox set (see screen grab), I want the users to be able to go back AND extend the Found set by adding, say, all records where the First name matches 'Phil'.




                          Essentially to build a search - whether or not by rerunning the same script (perhaps with parameters); or by all script steps to do all operations (Find and Extend) in the same long scrips (which seemed to be how some of your example scripts work) - on the same Browse Mode Layout as you kindly indicated to me in that earlier thread.


                          I did look through the general Scripting Finds thread you kindly point to - several times. But I wasn't sure (in the first place) whether to have two scripts attached to two buttons on a ('Add Criteria' to run the Extend script; and 'Submit' button to Perform the Find) on the same Layout.


                          I am prepared to start over, once I know what I should do. Also to send a sample FMP file etc. Thanks!


                          OTOH, if it were possible to script a logical OR for all the fields (checkboxes and non Category/checkboxes), if the end result were the same (all matches included in the Found set, which doesn't seem to be the way that the perform Find script step works, is it?), that would be OK too!


                          Though the idea of 'building' complex searches by repeatedly 'visiting' the same Search Layout and then Submitting a precise search for a Found set  is what I really want.