5 Replies Latest reply on Sep 6, 2016 4:41 PM by hunterkilla

    Hide results based on portal fields

    hunterkilla

      I have one layout that shows all bookings from today for a set period of time which is based on set fields and a perform find script.  The resulting records also have a portal that shows what items have been ordered.  Is there a way to do the script so if any items are NOT in the category ingredients it doesnt show that record. 

       

       

      If I try to do a find field based on the records having "Ingredients" in the category it shows nothing and assuming its because its in the portal

       

      I am trying to make it so I can show all upcoming jobs for the next two weeks but only if they have food items ie ingredients in the booking 

        • 1. Re: Hide results based on portal fields
          madmike6537

          How are you displaying the bookings - is it a list view on the layout with a portal on each record showing the ingredients? Or does it just show one booking at a time on the layout?

          • 2. Re: Hide results based on portal fields
            hunterkilla

            I am doing it via a list view and then running a script to say show all events from today for two weeks and only show bookings then on each record it has the booking details, ie date, name etc  and a portal showing the items booked   ie popcorn machine and popcorn ingredients..    so I want to hide any records that dont have ingredients

            • 3. Re: Hide results based on portal fields
              madmike6537

              Here is what I am thinking you could add to your script to do this:

               

              //Loop through bookings and associated ingredients to narrow found set to only bookings matching the ingredient

              set variable - ingredient you want to verify is part of the booking.

              Perform find - find the records for the bookings you want. //you are already doing this

              Go to first record

              Loop - exit after last record

              Set variable - primary key from bookings table of your current record you are on

              Go to layout - ingredients table

              perform find - search for foreign key = variable for primary key (assuming here that ingredients table is related to booking table)

                                 also in this find request - Ingredient name = $ingredient search variable

              Perform find

              If(Get(FoundCount) >= 1

              Go to layout Original

              Go to record - next

              Else

              Go to layout Original

              Omit Record

              End Loop

               

              I just made this up with no testing, but this should leave you with only the found record set that includes the ingredient you want.

               

              Edit: There might be a way to search the actual portal of each record, but I cant think of a way to do that, maybe someone else can comment. This is the best I got for now Let me know if you have questions.

              • 4. Re: Hide results based on portal fields
                madmike6537

                Is the ingredients table related to the bookings table? I just realized you said you want to find the ones that "dont have any ingredients" rather than one with a specific ingredient.

                 

                If they are related, you could change it to this:

                //Loop through bookings and associated ingredients to narrow found set to only bookings matching the ingredient

                Perform find - find the records for the bookings you want. //you are already doing this

                Go to first record

                Loop - exit after last record

                If ( Count (relationship::related field)

                Go to record - next

                Else

                Go to layout Original

                Omit Record

                End Loop

                • 5. Re: Hide results based on portal fields
                  hunterkilla

                  When I do this it finds two records but based on my currect records it should find 5. It seems to find the first record it finds with the correct field and then the last but none in between. Is there a reason its missing the others