3 Replies Latest reply on Nov 23, 2009 10:24 AM by philmodjunk

    Use Saved Finds Results to Create Groups

    KAmsinger

      Title

      Use Saved Finds Results to Create Groups

      Post

      Hi All,

       

      I was wondering if any one knows how to set up or create a script that after performing a specific find to take those records in that find set and create a group or "distribution list/group" of the find set results records?

       

      So for example, if I do a find of all people in NYC that are Men, and get 900 records from my find, I want to put those 900 records into a distribution lists/group called "NY MEN" and save that list/group so I always have access to it without having to perform the find again. Then I want it were anyone new who is added to my database that is also in NYC and is a Man will be added to the distribution list/group...

       

      Thx :)

      Kara 

       

       

        • 1. Re: Use Saved Finds Results to Create Groups
          philmodjunk
            

          If each record has a unique ID (serial number) field, then this can be done fairly simply.

           

          After performing the find, you script would do something like this:

           

          Go to Record [first]

          Loop

            Set Variable [$IDlist; Value : YourTable::YourIDField & "¶" & $IDList]

            Go To Record [Next; Exit after last]

          End Loop

          Go To layout [FoundSetLog (Foundsets)]

          New Record/Request

          Set Field [Foundsets::IDlist; $IDList]

          #Set any other fields in Foundsets you need to identify this found set record so that you can find it again.

           

          Foundsets is a table you would create with the IDList field plus any other you need in order to identify each such found set. Now you create a relationship:

          FoundSets::IDlist = YourTable::YourIDField

           

          From a layout listing FoundSets records you can use a script with Go To Related Record to recreate the found set.

           

          Warning: Go To Related Record is fairly poorly documented in Filemaker. If you are unfamiliar with this script step, see the following thread for more info and some cautions on how to safely use it:  The Complete Go To Related Record

           

          • 2. Re: Use Saved Finds Results to Create Groups
            KAmsinger
              

            Hi PhilModJunk,

             

            Thanks for your help. And yes, you are correct I am fairly new at this stuff. So here is my questions.

             

            First, the script you provided below would this go at the end of my "Find" script. Or is this a new script completely and if so, then how do I tell the "Find" Script to perform the below script after I do the "Find"?

             

            Secondly, Is the new table I am creating under my FMP file called "Contacts" that I am performing the saved "Find" in?

             

            Thirdly, how am I setting up a IDList to my saved finds so the correct "Saved Finds" is pulled in to my FoundSet table I am creating?

             

            Thx again for all your help you have no ideal how much this is teaching me :)

            Kara 

            • 3. Re: Use Saved Finds Results to Create Groups
              philmodjunk
                

              You can either add the script steps to the bottom of your existing script step or set it up as a separate script step. With a separate script, you can add a button to "save this found set?" which performs your script. You may also find the script step "Perform script" useful. This enables one script to perform another script that you've created in your database.

               

              "Secondly, Is the new table I am creating under my FMP file called "Contacts" that I am performing the saved "Find" in?"

              No. This should be a completely separate table where each record documents the saving of a different found set. That's the FoundSets table I describe when telling you to set up a relationship.

               

              "Thirdly, how am I setting up a IDList to my saved finds so the correct "Saved Finds" is pulled in to my FoundSet table I am creating?"

              That's where the relationship and Go To Related Records comes in. The list of values stored in the IDList field functions as an "OR" based match between your original table and your FoundSet table. It matches any records in your original table where the record ID matches the first value OR the second value OR the third value... etc.

              Starting from a Layout based on the FoundSets table, you would use GTRR with the "Show only related records | Match current record" option to recreate the original found set. Keep in mind that any new records that have been added that match the original criteria will not be brought up.