2 Replies Latest reply on Oct 7, 2012 8:30 PM by jb362

    Filtering records

    jb362

      Title

      Filtering records

      Post

            

           I’m trying to find records which fall within a specified date range and also have a specific Disposition ID

           Script steps…

           Set Variable[$StartDate; Value: Get(CurrentDate)]

           Set Variable[$EndDate; Value: $StartDate + 30]

           Set Variable[$DateRange; Value: $StartDate & “…” & $EndDate]

           Set Variable[$DispositionID; Value: 2]

           Go to Layout [“Appointments with 30 Days” (Appointments)]

           Enter Find Mode []

           Set Error Capture [On]

           Perform Find [Restore]

           The script steps in the screen shot below end up finding every record.

           If I remove either of the Actions from the Find Requests the result is the set specified by that request.

           Obviously my logic is supect but here’s what I think the above Find Requests mean.

           First find the set of records which are within the specified Date Range.

           Then the found set is further filtered to also satisfy the Disposition ID requirement.

           What’s the error in my logic?

           FWIW: I’m a hobbyist and still pretty new to FMP.

           Thanks.

      Find_Requests.JPG

        • 1. Re: Filtering records
          philmodjunk

               What you have created are TWO find requests, each with different criteria specified instead of ONE find request with two sets of criteria specified.

               As a result, you are finding all records that are either within the given date range OR that have the specified Disposition ID.

               Here's how to fix it when using a stored find request:

               Click the second request, then click Delete.

               Click the first request and then click Edit.

               In the Edit Find Request dialog, click Disposition ID and enter the name of the variable, Click Add.

               Now you have one request with two criteria.

               My personal preference, however, is not to use the variables and stored request in the first place. Instead, I'd script it like this:

               Go To Layout [appointments]
               Enter FInd Mode [] ---> clear the pause check box.
               Set Field [appointments::Appointment Date ; Get ( CurrentDate ) & "..." & Get ( CurrentDate ) + 30 ]
               Set Field [appointments::Disposition ID ; 2 ]
               Set Error Capture [on]
               Perform Find []

               The script is only a little simpler than yours, but you can see all the criteria specified without having to open a dialog box to see it.

          • 2. Re: Filtering records
            jb362

                 Phil:

                 I now realize those script steps were being treated like an “OR” and not as an “AND” which is what I thought I was doing.

                 Thanks for the clarification and your suggested coding technique.

                 Jerry