8 Replies Latest reply on Jan 13, 2016 9:02 AM by Abingdon

    Quick way to count number of 'valid' portals?

    Abingdon

      I have a layout with 5 portals on it, each showing 3 records, all from the same relationship.  Portal one shows records 1-3, portal two shows records 3-4 etc. etc.  That gives me a maximum of 18 records that may be showing in the portals at any one time.

       

      I need to be able to set a variable with the total number of portal records that are being shown.  E.g., if portals one and two re 'full' that gives me 6 records, if only 2 rows of portal three have data in them then that gives me a total of 8 records being shown via the portals.  There may be more than 18 records able to be shown at any one time but I need to know how many are actually being shown via the portals (not the total number of related records)

       

      Short of scripting a visit to each portal row and seeing if it's got any data in it, Is there a 'fast' way to do this?

       

      Basically, it's a product image database.  A product type may have any number of images associated with it. A user selects the product type and the portals show the associated product images.  If there are more than 18 product images, the user can click a 'next' button which loads the next set of images.  Could be another 18 or, say, only the remaining 5.  I need to make the 'next' button invisible if there are not any more images to load.  Hence the need to count the number of images left to view.

       

      I can calculate the total number of images available for any selected product; it's the 'counting up' of images left to view that I am having a problem with.

       

      Trust this makes sense and thank you as always.

        • 1. Re: Quick way to count number of 'valid' portals?
          macwombat

          How does your 'next' button load the next set of images?  Does it update a field that is referenced in the relationship?

          • 2. Re: Quick way to count number of 'valid' portals?
            Abingdon

            Hi Chris,

            Many thanks for your help.

            Each image has a unique id.  When the user clicks the 'next' button a script sets a global field in the Parent record with the image id of the image in Row 3 of Portal 6, i.e. the last image on the layout.  This global field is used in the relationship.  The relationship says show records when:

            Product Type in the Parent record = the Product Type in the Child record

            and

            the global field in the Parent record <= to the image id in the Child record.

             

            This then shows the next set of images.

            • 3. Re: Quick way to count number of 'valid' portals?
              macwombat

              In the Inspector on the data tab, under the Behaviour settings, there is a "Hide object when" calculation.  Put in this calculation, substituting your child table and field name into it:

               

              Count ( ChildTable::ChildName )  ≤ 18

               

              HTH   Chris.

              • 4. Re: Quick way to count number of 'valid' portals?
                Abingdon

                Hi Chris,

                 

                I have used 'Hide' on other places on the database.  However the calculation you suggest above it won't do the job I need here.  If you can imagine, I have for example 28 images for a product, the first 'set' of images is 1 to 18, the user clicks 'next' and then sees the remaining 10 images, there are no further images to click to, it is at that point that I need to hide the button.  However, the total number of images will still be 28 so the button will not hide using that calculation.

                That's the reason I need a count of how many images the user has viewed so far so that I can do something like, If total images available minus images views < 18, then hide the button.

                The only way I can think of doing this is to count the number of 'blank' portal rows may be on the 'final' page - if that figure is less than 18 it means no more images to view, hide the button.

                 

                Sorry to be so taxing.  Much appreciate your help.

                • 5. Re: Quick way to count number of 'valid' portals?
                  Mike_Mitchell

                  Can you not do a Count ( relatedTable::key )? That should give you the current number of records that are populated.

                  • 6. Re: Quick way to count number of 'valid' portals?
                    Abingdon

                    Hi Mike,

                     

                    Thank you for this, sorry I missed in replying to Chris!  My reply to him applies I think, unless I'm missing something?

                    • 7. Re: Quick way to count number of 'valid' portals?
                      Mike_Mitchell

                      I might be wrong, but if you have a relationship that's based on a global field, then the Count ( ) should apply the filter. So if you have a total of 28 images (for example) and you're on the first set, then Count ( ) should show 18. Click "Next", and the remaining 10 images show up - so Count ( ) then returns 10.

                       

                      If you're concerned about not showing the Next button if there are exactly 18 records, you can create another relationship that doesn't have the filter and use that to compare the screen you're on times 18 with the total count.

                      • 8. Re: Quick way to count number of 'valid' portals?
                        Abingdon

                        Mike and Chris, you are absolutely right!  My apologies.  I was looking at the total record count using a relationship from the Product Type - of course it was always giving me the total number of records.

                         

                        My apologies again and thank you for persisting in giving me the correct answer when I had my metaphorical fingers in my ears shouting 'No, no, no...'