10 Replies Latest reply on Nov 26, 2012 6:55 AM by ariley

    Matching two lists

    ariley

      I have two lists that I need to match against each other. I have a list of projects that can have a carriage return limited list of locations, such as

       

      NY

      LA

      PDX.

       

      I have a filter that people can check where they can choose PDX only or NY and LA or LA and PDX. I need to constrain my previous find (from another criteria) to show the records that have any of the selected locations. I am looping through the records, but for the love of... I can't match the lists properly. PatternCount gives me partial matches. If I choose LA and NY, it won't give me the record that has NY and PDX in it, but it's also not even totally consistent.

       

      I also tried Agnes Barouh's custom function FilterList, but that gives me an error about the attribute, which I have in quotes and caps.

       

      Any ideas out there?

       

      Thanks in advance,

      Agi

        • 1. Re: Matching two lists
          comment

          I think you are looking for the FilterValues() function. I didn't understand your workflow completely, but =

           

          not IsEmpty ( FilterValues ( "LA¶NY" ; "NY¶PDX" ) )

           

          will return True.

          • 2. Re: Matching two lists
            lhoong

            Hi Agnes,

             

            Are the location entries for each project record captured in a consistent value order during data entry?  If so, using the FilterValues( ) during filtering may give better results than PatternCount( ). You can use the location field auto-enter option to enforce the value order, if needed.

             

            I'll see if I can whip up an example file, if you're interested.

             

            Lee.

            =================

            Binary Assist

            220 Gaines Oak Way

            Suwanee, GA 30024

            Voice: (678) 313-5604

            Internet: lhoong@binaryassist.com

            Website: www.binaryassist.com

             

            FileMaker Certified Developer

            • 3. Re: Matching two lists
              lhoong

              Here's a sample file illustrating the use of FilterValues( ) to filter records, regardless of the entry order for the values in the Location field.

               

              Hope it's the type of filtering you were looking for...?

               

              Lee.

              =================

              Binary Assist

              220 Gaines Oak Way

              Suwanee, GA 30024

              Voice: (678) 313-5604

              Internet: lhoong@binaryassist.com

              Website: www.binaryassist.com

               

              FileMaker Certified Developer

              • 4. Re: Matching two lists
                BruceRobertson

                Lee: nice simple solution.

                 

                Looking at your script, I see this statement:

                 

                Set Variable [ $Context; Value:ExtractData ( $ScriptNameParams ; "context" ; 1 ) ]  

                 

                It appears to be unused in your example but looks like something that you probably use commonly.

                 

                I can probably guess what it does but - could you explain a bit?

                • 5. Re: Matching two lists
                  lhoong

                  Bruce,

                   

                  I pass script parameters to my scripts as XML, which is parsed using the custom function ExtractData( ) - the context parameter is captured and stored as $Context. By default, it's usually the layout name when the script is run, but it could be any value that distinguishes the context under which the script should operate. The script can then determine how to handle the current context (e.g. branching to sub-routines) as appropriate, allowing the script to be "shared" across layouts, tabs, etc.

                   

                  Many useful XML-handling custom functions, like the ones I use, can be found at Brian Dunning's site and at FileMakerCustomFunctions. Hope that makes sense.

                   

                  Lee.

                  =================

                  Binary Assist

                  220 Gaines Oak Way

                  Suwanee, GA 30024

                  Voice: (678) 313-5604

                  Internet: lhoong@binaryassist.com

                  Website: www.binaryassist.com

                   

                  FileMaker Certified Developer

                  • 6. Re: Matching two lists
                    lhoong

                    Bruce,

                     

                    Yikes! I just realized there is an error in the Set Variable step. The script-parameter-handling steps should be:

                     

                    Set Variable [ $FilterRecsParams; Value:Get ( ScriptParameter ) ]

                    Set Variable [ $Context; Value:ExtractData ( $FilterRecsParams ; "context" ; 1 ) ]

                     

                    Otherwise, it won't work correctly. Too much Thanksgiving turkey, perhaps...

                     

                    Lee.

                    =================

                    Binary Assist

                    220 Gaines Oak Way

                    Suwanee, GA 30024

                    Voice: (678) 313-5604

                    Internet: lhoong@binaryassist.com

                    Website: www.binaryassist.com

                     

                    FileMaker Certified Developer

                     

                    Edit: Posting by email messed up the first script step above - fixed.

                    • 7. Re: Matching two lists
                      BruceRobertson

                      Glad we got that straightened out!

                       

                      Nevertheless - I'd still like to hear more about $ScriptNameParams.

                       

                      I recognize that you aren't using them here.

                       

                      It looks like you probably parse a script name for expected variables and then use the extract routine to obtain those values.

                       

                      So maybe you have a script:

                       

                      Delete Contact [ ContactID ]

                       

                      And you parse your XML variable for "ContactID"

                       

                      Could you post an example where you are using this method?

                      • 8. Re: Matching two lists
                        ariley

                        For some reason I didn't get notifications about the responses, so I'm just reading through them. I will start by trying the filtervalues.

                         

                        I'll let you know how that goes.

                         

                        Thank you, All, so much for the responses.

                         

                        Best,

                        Agi

                        • 9. Re: Matching two lists
                          lhoong

                          Bruce,

                           

                          Rather than take this forum thread further off-topic, let's move this discussion of script parameters back-channel. I'll send you a sample of how I use $ScriptNameParams.

                           

                          Lee.

                          =================

                          Binary Assist

                          220 Gaines Oak Way

                          Suwanee, GA 30024

                          Voice: (678) 313-5604

                          Internet: lhoong@binaryassist.com

                          Website: www.binaryassist.com

                           

                          FileMaker Certified Developer

                          • 10. Re: Matching two lists
                            ariley

                            Thank you. Sometimes I wonder how the simplest things just elude me... :-)