4 Replies Latest reply on Sep 2, 2013 3:24 PM by ruderick

    Can we use variables in "Perform Find" script step?

    yuichim

      Title

      Can we use variables in "Perform Find" script step?

      Post

      For some reason, I can not create a Perform Find script step with multiple criteria.
      There are 2 fieds that I have set variables and would like to use as range find.
      Here is what I did.

      Find:

      $username = Get(AccountName)
      AND
      daterange = $datestart ... $dateend

      However, the script is not performing correct find....  instead of putting the variable, it puts the actual "$datestart ... $dateend"

      Any help much appreciated...

        • 1. Re: Can we use variables in "Perform Find" script step?
          Sorbsbuster

          I think you have shortened your description of the script steps to the point of (my) confusion.  For example, I don't know where you defined the dates. This works:

           

          Set Variable ($UserName , Get ( AccountName ) )

          Set Variable ($DateRange , "1/1/2011...31/12/2011")

          Enter Find Mode

          Set Field ( UserName ; $UserName )

          Set Field ( Date ; $DateRange )

          Perform Find

          • 2. Re: Can we use variables in "Perform Find" script step?
            philmodjunk

            I believe that our OP is using

            Perform FInd [Restore] with $Date1...$Date2 as criteria in the stored find criteria. That won't work as that option for the script step will not evaluate expressions such as this.

            USe Sorbsbuster's script or this alternative that's closer to what you already have:

            Set Variable ($UserName , value: Get ( AccountName ) )

            Set Variable ($Date1 , value: YourTable::date1field)

            Set Variable ($Date2 , value: YourTable::date2field)

            Enter Find Mode [] //clear the pause check box

            Set Field ( UserName ; $UserName )

            Set Field ( Date ; $Date1 & "..." & $Date2 )

            Set error capture [on]//keeps dialog box from interrupting script if no records are found

            Perform Find [] //no criteria specified here

            • 3. Re: Can we use variables in "Perform Find" script step?
              Corné

              I love this forum. Get's me the right info everytime! Smile

              • 4. Re: Can we use variables in "Perform Find" script step?
                ruderick

                     It may be a little late for your developments now but, you inspired me to get to a similar solution that actually uses variables and don't need to Enter Find Mode in the script, just using the Perform Find[] script step. You can set a variable like this:

                     SetVariable[ $dateRange; Value:$Date1 & "..." & $Date2 ]

                     Perform Find[ Restore ] // and here you assign the field you want to search for with a criteria which is just the variable, no comparators, nothing.

                     It seems that FM gets the content of "Criteria" and uses it if no operator is found.

                     Hope it helps.