5 Replies Latest reply on Apr 28, 2017 5:55 AM by Jason Wood

    Results based on an optional parameter


      Hi all,


      I have a script I use on three different buttons - economy of scripting on my part which seems to work.  It basically extracts information from a table.  On two of the buttons I use an optional parameter which changes direction the script as in


      1)     Country = 'UK'


      2)     Active = 'Yes'


      Both of these parameters work perfectly well.  I want to add a parameter to another button which effectively says 'filter on whatever county shows in the county search box'. (I have a drop-down box with all counties listed, I want the result of the drop down to be the parameter result.)


      I have tried

      County = CountySearch

      County = 'CountySearch'

      County = "CountySearch"


      with no effect.  Can anyone advise how I can get the parameter to filter based on whatever is found in the CountySearch box?





        • 1. Re: Results based on an optional parameter
          Johan Hedman

          Then what I would do is to split up your script into 3 different scripts. Have one script that you call with your parameters and then have that script run the selected script depending on what your parameter are


          You County Search field is a field, you can not do ' or ". You need to


          If ( Get(ScriptParameter) = "UK" and CountySearch = "YourValue" )

               Then do script 1

          Else if ( Get(ScriptParameter) = "UK" and CountySearch = "YourValue2"

               Do another script

          Else if ( xxx

               Do another script

          End if

          • 2. Re: Results based on an optional parameter

            can you post your script here?


            • 3. Re: Results based on an optional parameter
              Magnus Fransson

              Hi jackmac,


              This is pure speculation, but I believe you should write something like:


              "County = " & CountySearch


              Or perhaps:


              "County = '" & CounySearch & "'"


              With best regards Magnus Fransson.

              • 4. Re: Results based on an optional parameter
                Magnus Fransson

                Hi jackmac,


                If you have FileMaker Pro Advanced you can make good use of custom functions to pass multiple named values to and from a script.


                Six Fried Rice has two blog post that describe their version of "dictionary" functions.


                Part one: Passing Multiple Parameters to Scripts – Advanced

                Part two: FileMaker Dictionary Functions


                With best regards Magnus Fransson.

                • 5. Re: Results based on an optional parameter
                  Jason Wood

                  I do think that Magnus correctly identified your immediate problem, which is that you didn't know how to write the calculation you wanted. But once you do this, you're still left with the problem of then how to pull the country out again once you're inside the script. Which isn't terribly difficult but Johan suggests a better approach: Don't bother putting field data in the script parameter because you can easily get that from inside your script. Your script parameter should simply by "Active" or "Country".


                  If [ Get(ScriptParameter) = "Active" ]

                       [ Do things... ]

                  Else if [ Get(ScriptParameter) = "Country" ]

                       $country = Table::CountrySearch

                        [ Do things... ]

                  End if

                  [ Do things that apply to all conditions here ]




                  None of this is going to filter a drop-down menu, which seems to be what you're asking for. You do not need a script to filter a popup menu... so maybe you should provide some more details on what you're trying to do and what the script is for.