4 Replies Latest reply on Aug 22, 2011 11:57 AM by NaturSalus

    Multiple "And" Find Script

    NaturSalus

      Title

      Multiple "And" Find Script

      Post

      Hello,

      I have a table named Food where I list several food characteristics.

      Relevant Food table fields:

      __kpFoodID

      FoodName

      FoodCategory

      FoodSubCategory

      BloodTypeASecretor

      BloodTypeANonSecretor

      BloodTypeBSecretor

      BloodTypeBNonSecretor

      BloodTypeABSecretor

      BloodTypeABNonSecretor

      BloodTypeOSecretor

      BloodTypeONonSecretor

       

      So, depending on the persons BloodType and wether he/she is Secretor or Non Secretor a particular Food can be:  Avoid (detrimental), Beneficial, Neutral.

      My final objective is to have four types of food report, one for each blood type, based on the food suitability: Avoid, Beneficial, Neutral 

      FOOD REPORT

      BLOOD TYPE:

      Avoid                              Beneficial                           Neutral

      Food Category                 Food Category                    Food Category 

      Food SubCategory            Food SubCategory              Food SubCategory 

      FoodName                       FoodName                         FoodName  

       

      So I need 4 scripts, one for each blood type, that will find and sort the records. Finally, I will associate each script to its button: A Type Food, B Type Food, AB Type Food, O Type Food.

      I have a working Find and Sort script  based on just one criteria for each blood type.

      So, for the A Blood Type I have the following script to find out the "Beneficial" foods:

      Find_BT_A_Beneficial script is the following

      Enter Find Mode [ ]
      Set Field [ Food::BloodTypeASecretor; "Beneficial" ]
      New Record/Request
      Set Field [ Food::BloodTypeANonSecretor; "Beneficial" ]
      Set Error Capture [ On ]
      Perform Find [ ]
      Perform Script [ “Food Record Sorting”]

       

      Food Record Sorting Script:

      Enter Browse Mode

      Go to Layout [ “Alimentos Recomendados” (Food) ]
      Sort Records [ Specified Sort Order: FoodCategory::FoodCategory; ascending FoodSubcategoy::FoodSubcategory; scending Food::FoodName; ascending ]
      [ Restore; No dialog ]
      Enter Preview Mode [ Pause ]
      Enter Browse Mode []
      Go to Layout [ original layout ]

       

      I would like to be able to modif ythe Find_BT_A_Beneficial script so that it finds and sorts all the food records that are: Avoid, Beneficial & Neutral for both Blood Type A Secretors and Blood Type A NonSecretors.

      Since I have tried without success some modifications, my question is:

      How can I modify the Find_BT_A_Beneficial script so that the found set includes:

      Foods to Avoid & Beneficial & Neutral for the Secretor Blood Type A

      &

      Foods to Avoid & Beneficial & Neutral for the NonSecretor Blood Type A?

       

      Thanks

        • 1. Re: Multiple "And" Find Script
          philmodjunk

          I think my lack of "subject Matter expertise" on the topics addressed by your database is confusing me here.

          If you are finding all records where the foods are either avoid, beneficial, or neutral for bth Secretor type A and nonSecretor type A, doesn't that specify that you are finding all records in your table? I can't imagine any records that don't match those options here. It may just be that you need to sort your records by the secretor blood type field, then by the avoid, beneficial and neutral values to group the records into meaningful groups.

          The fact that you show three columns for this data is also an issue that will complicate this. It may be that you can't perform a find at all but may need to use portals with different portal filters and/or portal relationships in order to present your data in these columns...

          • 2. Re: Multiple "And" Find Script
            NaturSalus

            Hello Phil,

             

            Thanks for looking into my question.

            If you are finding all records where the foods are either avoid, beneficial, or neutral for bth Secretor type A and nonSecretor type A, doesn't that specify that you are finding all records in your table?

            Nope.

            If you are finding all records where the foods are either avoid, beneficial, or neutral for bth Secretor type A and nonSecretor type A, doesn't that specify that you are finding all food records as they relate to Blood Type A.

            All food records = those related to Blood Type A + those related to Blood Type B + those related to Blood Type AB + those related to Blood Type O

             Depending on the blood type, the number of different records based just on the "food suitability" are something like: 

            number of Foods ( number ofFoodName)    * 4 (number of blood types) * 2 (number of blood type secretion status) * 3 (number of food suitability for each blood type and secretion type)

            Out of all these "possible records" based on their food suitability depending of the blood type, I want to carry out just 4 findings:

             

            Blood type A finding: all the FoodNames that are unsuitable (avoid) + suitable (beneficial) + neutral (neutral) for people with Blood type A Secretor + Blood type A NonSecretor.

            Blood type B finding: all the FoodNames that are unsuitable (avoid) + suitable (beneficial) + neutral (neutral) for people with Blood type B Secretor + Blood type B NonSecretor.

            Blood type AB finding: all the FoodNames that are unsuitable (avoid) + suitable (beneficial) + neutral (neutral) for people with Blood type AB Secretor + Blood type AB NonSecretor.

            Blood type O finding: all the FoodNames that are unsuitable (avoid) + suitable (beneficial) + neutral (neutral) for people with Blood type O Secretor + Blood type O NonSecretor.

             

            I'll try to clarify my question from a different point of view. Currently, for each blood type, I have three "Find" scripts, each one associated to a button:

            Beneficial

            Avoid

            Neutral

             

            So since I want to list in a report all the Beneficial, Avoid and Neutral foods for each blood type, I was wondering if it is possible to group the aforementioned 3 find scripts into just one find script. And do this for each blood type. So, is it possible to modify my current Find_BT_A_Beneficial script so that to the "Beneficial" value I could add "Avoid" and "Neutral" adn rename it: Find_BT_A_All?

             

            The fact that you show three columns for this data is also an issue that will complicate this. It may be that you can't perform a find at all but may need to use portals with different portal filters and/or portal relationships in order to present your data in these columns...

            Okay if what I am asking makes any sense to you, let's focus on the finding part of my question first.

             

            Thanks

            • 3. Re: Multiple "And" Find Script
              philmodjunk

              My biology class memories are coming back to me. A "secretor" secrets the "RH Factor"? (So you are looking for all foods for a specified blood type but need to organize the found records in to groups by RH factor and the three suitability categories of beneficial, Avoid and Neutral...

              If I am right, you can simplify this query a lot by restructuring your data.

              Use two fields: one for Type, O, AB, A, B and one for RH factor (Positive (Secretor )  or Negative (Non-Secretor).

              This way your find simply needs to specify the blood type, then you can sort the results the Food Suitability field (You haven't identified that field here...) to group them by "avoid", "beneficial" and "neutral".

              To answer your specific question, if you want to find all records that match criterion 1 or criterion 2 or criterion 3..., you have two different approaches that can produce exactly the same results:

              1. Enter find mode and specify criteria for Criterion 1. Create a new find request (new Record/Request) and specify criterion for "criterion 2". Repeat to specify criteria for "Criterion 3". Now perform the find.
              2. Perform find for first group of records.
                Enter find mode and specify criteria for second group. Use extend found set, instead of perform find to add found records to those you already found for the first group of records.
                Repeat process to add records for the third group...
              • 4. Re: Multiple "And" Find Script
                NaturSalus

                Phil,

                Many thanks for your clear explanations and suggestions.