1 Reply Latest reply on Aug 18, 2016 6:39 PM by philmodjunk

    Script approach to remove find criteria on a field?


      I have a few search criteria that I'd like to be able to choose from in my record set, and then have FileMaker show records including these criteria; however, I'd like to do it via a script.


      In my solution I have a field for date, and then a field for "problem type". The problem type is blank by default, but if a problem exists then it can be of "type 1" or "type 2". The date field is always auto-populated.


      I have global fields to represent "search values" for these two fields. For the globals, I have "StartDate" and "EndDate", and then I have a global called "TypeSearch" for folks to enter a problem type (by value list).


      I am using these globals to provide stereotyped options for a relatively filemaker-naive userbase to select from in order to filter the data in the layouts. I am then attempting to use a script for populating a find request from these globals. The script basically checks for the length of a global and defines a variable as either the global's value, or as "*" if the value is blank. It then uses a "Perform Find" step to apply the values of the variables to their respective field in a search query.


      The problem with this is that the use of "*" as the variable omits blank fields in the search, such as might be the case with the problem field above. I cannot use "=" either, as this will simply invert the results. There appears to be no wildcard that "clears" the search on a given field. I have also tried sequential "Perform Find" steps; however, each does not include the results from the prior step.


      The "Modify Find" option would work if it was scriptable, but it just changes the mode of the interface to Find. I would prefer to not enter Find mode at all, and rely on script steps to designate values to find, or clear them for a specific field. Is this possible?

        • 1. Re: Script approach to remove find criteria on a field?

          It's not clear what you are trying to accomplish with your criteria. If the user did not specify criteria for a given field, what do you want to happen, not have that criteria affect the results at all?


          If so, just don't assign any criteria to the field while in find mode. So your script might look like:


          Enter Find Mode [] ---> No pause selected

          Set Field [YourTable::ProblemType ; YourTable::globalForTypeSearch ]
          Set Field [ YourTable::DateFIeld ; If ( IsEmpty ( YourTable::globalEndDate ) ;

                                                                     YourTable::globalStartDate ;

                                                                      YourTable::GlobalStartDate & "..." & YourTable::GlobalEndDate ) ]

          Set Error Capture [on]
          Perform Find []


          For more examples of how to use a script to perform a find: Scripted Find Examples.