2 Replies Latest reply on Mar 21, 2011 2:55 PM by Steveb

    Using multiple global fields to filter a list

    Steveb

      Title

      Using multiple global fields to filter a list

      Post

      Hi,

      I'm busy setting up my first database and I've been doing fine following along on the VTC tutorials but I recently run into a problem which no amount of searching seems to solve.

      Right now I'm trying to build a list view which will filter clients in list mode based on a set of global fields set in the header.  I want to be able to find and sort these contacts based on more than one global field. i.e. find all my clients that do not have orders in currently but have also not been contacted for this season's orders or alternatively who have been contacted but have not replied.

      'xcurrent order' is based on a value list with 3 values "Yes", "No", and "Both", the none global 'current order' only has "Yes" and "No" and uses a different value list
      'xstatus' has 5 values "Not Contacted", "Contacted", "Replied", "Reminded", and "Not Teaching/On Sabbatical"


      Right now my script looks like this:

      Set Variable [$xcurrent order; Value:Professor::xcurrent order]
      Set Variable [$xstatus; Value:Professor::xstatus]
      If [$xcurrent order = "Both"]
           Perform Find [Restore] (find criteria: Professor::status = Professor::xstatus)
      Else
           Perform Find [Restore] (find criteria: Professor::current order = Professor::xcurrent order)
           Constrain Found Set [Restore] (find criteria: Professor::status = Professor::xstatus)
      End if
      Sort Records (by last name)


      Any suggestions would be very much appreciated!











        • 1. Re: Using multiple global fields to filter a list
          philmodjunk

          The nice thing about global fields is that you can reference the contents of them while in find mode.

          Take these two scripted examples that may give you some ideas in how to do this:

          #Find all records where Fruit is the name specified in gFruit AND Color is the color specified in gColor
          Enter Find Mode[]//clear pause check box
          Set Field [Table::Fruit ; Table::gFruit]
          Set Field [Table::Color ; Table::gColor]
          Set Error Capture [on]
          Perform Find []

          #Find all records where Fruit is the name specified in gFruit OR Color is the color specified in gColor
          Enter Find Mode[]//clear pause check box
          Set Field [Table::Fruit ; Table::gFruit]
          New Record/Request
          Set Field [Table::Color ; Table::gColor]
          Set Error Capture [on]
          Perform Find []

          I always try to avoid Perform Find [restore]. It works, but when you come back later to look at your script, you have to open up the script step before you can see what criteria was used in it. The above method clearly lists the source of each value used as search criteria as well as any operators used with them directly in the scripts.

          • 2. Re: Using multiple global fields to filter a list
            Steveb
            Awesome!!!  That worked out perfectly! I will be staying well away from the Perform Find [Restore] from now on. Thanks for the speedy and helpful reply. -Steve