2 Replies Latest reply on Mar 14, 2013 10:54 AM by RonaldCarr

    Can't make a Find work in script

    RonaldCarr

      Title

      Can't make a Find work in script

      Post


           I have the following script, where I get a Start and end date then try to do a find on a layout.

           The Find fails with a "find criteria is not valid". The shown criteria is the variable name $vstartdate, so obviously the date is not being properly translated into the find.

           Where have I gone wrong here?

            

      Script_Find_problem.jpg

        • 1. Re: Can't make a Find work in script
          philmodjunk

               Stored finds can't evaluate expressions. You have to enter either literal data or just the name of a variable--can't add anything beyond the variable name.

               But since you already have the dates in global fields, you do not need the variables at all.

               Do it this way:

               Enter Find mode [] -->no stored criteria, clear the pause check box.
               Set Field [Visits::VistitDate ; Globals::gStartDate & "..." & Globals::gEndDate ]
               Perform Find[]

               For other examples of scripted finds that use global fields and set field script steps, see: Scripted Find Examples

               Note: because you are using Show Custom Dialog, it's possible to enter invalid dates as well as dates where EndDate comes before StartDate. You may want to add some code that checks the data in the two fields before attempting to find records.

          • 2. Re: Can't make a Find work in script
            RonaldCarr

                 That did indeed do it.

                 Thank you!

                 I'll learn this thing yet.

                 Ron