4 Replies Latest reply on Apr 13, 2016 10:42 AM by DavidGunter

    Find using current date

    DavidGunter

      My script to locate records finding by balance owing >0 and within 60 days of arrival date looks like this;

       

      Go to layout: Reservation

      Perform Find[Specified Find requests; Find records; Criteria: Reservation:: balance owing ">"

      Constrain FoundSet [Specified Find requests; Find records; Criteria: Reservation:: arrives < //+60

       

      The second statement is problematic. I tried using get < (currentdate) +60   but that fails also.

       

      I can't use a global field for arrives as that would change all the dates.  Any suggestions would be greatly appreciated.

        • 1. Re: Find using current date
          DavidGunter

          The first script statement reads Find records; Criteria: Reservation:: balance owing ">0"

          • 2. Re: Find using current date
            Mike_Mitchell

            You can't perform a Find with a dynamic value unless you use a variable. Best practice would structure your script like this:

             

            Go to Layout [ Reservation ]

            Enter Find Mode [ ]

            Set Field [ Reservation::balance owing ; Value: ">0" ]

            Set Field [ Reservation::arrives ; Value: "<" & Get ( CurrentDate ) + 60 ]

            Set Error Capture [ On ]

            Perform Find [ ]

            Set Error Capture [ Off ]

            If [ Get ( FoundCount ) < 1 ]

                 {do error trapping stuff here}

            End If

             

            You don't need the Constrain; just put both criteria on the same Find request.

             

            HTH

             

            Mike

             

            Edit: Second Set Field command was wrong. Sorry.

            • 3. Re: Find using current date
              karendweaver

              Try setting a variable - I find that works better than a calculation in the find box.  So set a variable $findDate to "<" & Get ( CurrentDate) + 60,  The ampersand is required to make the calculation work properly.

               

              then in your find, you don't need to constrain the found set.  Two criteria acts like an "And".  So use the criteria

              Reservation:: balance owing ">0"  AND Reservation::arrives = $findDate

               

              If you are still having trouble, try doing a manual find with those criteria.  As your find date, use the current date - 60 because that is what the calculation should return.  That way you can also verify there are records meeting your criteria and it isn't really failing, just finding no records.  Once you get the manual find to work properly, you can try setting the script again.  Most likely, there's a typo somewhere in your calculation or there's a problem with the logic that will show up with a manual find.

              • 4. Re: Find using current date
                DavidGunter

                Hi Karen,

                 

                The ampersand was the trick.

                 

                Thanks