1 2 Previous Next 21 Replies Latest reply on Oct 20, 2012 8:00 PM by LaRetta_1

    Display a message in an empty Portal

    brian.curran

      Title

      Display a message in an empty Portal

      Post

           Hi,
           I would like to display a default text message in a portal if there are no records, can this be done easily?

           For example:
           Portal of product A that has zero records displays a "Please re-order product A"

           Thanks
           Brian.

        • 1. Re: Display a message in an empty Portal
          philmodjunk

               Add layout text to your layout that says "Please re-order product A". Put it on top of the portal.

               Use conditional formatting to change the font size to a size larger than or equal to 100 pts to make the text disappear.

               A possible conditional format expression for changing the size to hide the text:

               Count ( PortalTable::PrimaryKey ) // You can use any field in the portal table that is never empty.

          • 2. Re: Display a message in an empty Portal
            brian.curran

                 Hi Phil,
                 I'm struggling to get this to work. I tried something similar last night but had the same problem unfortunately.

                 For testing purposes, I conditionally formatted the background of the text box to yellow and this results in a yellow portal row for every row that has a record. However, my "Please re-order product A" text doesn't appear when the portal has no records at all.

            • 3. Re: Display a message in an empty Portal
              philmodjunk

                   Try placing the layout text outside the portal. Does it now work?

              • 4. Re: Display a message in an empty Portal
                brian.curran

                     No, it's now a yellow text box whether the portal row is empty or full...

                • 5. Re: Display a message in an empty Portal
                  philmodjunk

                       But I didn't suggest a yellow text box. I suggested a text object with a conditoinal format to change the size of the text, not the color.

                       See the image file for what I have in mind. See the demo file: https://dl.dropbox.com/u/78737945/ConditionalLayoutTextDemo.fp7

                       To see how I did it. (If you are using FileMaker 12, open this file from the File menu to get  converted copy.

                  • 6. Re: Display a message in an empty Portal
                    brian.curran

                         I couldn't tell whether it was working or not so I gave it a yellow background just for testing purposes. The problem was due to me using an incorrect Table::Field in the conditional format! When in doubt, look for the obvious :)

                         Many thanks Phil...

                    • 7. Re: Display a message in an empty Portal
                      LaRetta_1

                           Hey Phil,

                           I wouldn't suggest Count() to test for presence of portal records for displaying conditional formatting.  Conditional formatting always runs from perspective of current layout (in this case the parent) and it evaluates in stacking order (in case of portals, in portal row order, top to bottom).  Count() also must iterate through every record (in this case) before it can return a result - it does not short-circuit like Case(), If() and others.  It is similar to PatternCount() which has to evaluate text through an entire field before it can conclude whereas Position() will stop when it finds its answer.

                           Using Count() in conditional formatting would look like this:

                           Portal row 1, count all of this Parent's children, evaluate, return result and display
                           Portal row 2, count all of this Parent's children, evaluate, return result and display
                           ... and on through every single child record displayed on the layout.

                           I would suggest instead if you want to evaluate if there ARE child records ...
                           If the ID is numeric, use:  childTable::ID  <--- producing a boolean true (1) if there are any children because ANY ID returned is 'true'
                           If the ID is text, use:  not IsEmpty ( childTable::ID )

                           And if you want to evaluate if there are NOT child records ...
                           If the ID is numeric, use:  not childTable::ID
                           If the ID is text, use:  IsEmpty ( childTable::ID )

                           I realize we squibble a bit (in friendly ways) over whether saving a nanosecond is worth it but this would be a heavy hit.  Regardless, every nanosecond DOES count because  they compound on top of each other and before you know it you have a solution that runs like a dog and sinks like a stone.  And with the world moving to mobile, WAN and the cloud, we simply can't afford to be wasteful or we will be out of business. :^)

                      • 8. Re: Display a message in an empty Portal
                        philmodjunk

                             Good point. Fact is that I almost always use either

                             IsEmpty ( )

                             Or, if the foreign key is a number field, I just put the reference to the related key field with no function call at all.

                             Not sure why my brain spit out "Count" in this post yesterday...

                        • 9. Re: Display a message in an empty Portal
                          brian.curran

                               So..., do I need to change anything? :)

                          • 10. Re: Display a message in an empty Portal
                            philmodjunk

                                 You don't have to, but LaRetta makes a good point that the calculation will evaluate a touch faster if you use Not IsEmpty ( ) in place of Count.

                            • 11. Re: Display a message in an empty Portal
                              brian.curran

                                   Thanks Phil, I couldn't get any of the options to work consistently so have reverted back to the Count ()

                              • 12. Re: Display a message in an empty Portal
                                LaRetta_1

                                     I guess "a touch" is a relative term ... you are forcing FM to evaluate every child record (for that parent) again and again through every row when all the row needs to know is whether ANY child exists!  This is NOT a small thing at all.  By just checking for a related record, the count goes ONE then stops insteading of continuing and counting ALL OF THEM.  Now multiply that wasted time by the number of row!!

                                     And when you scroll records (either parent or child) the difference can be seen particularly across WAN.  I strongly recommend ditching Count() for conditional formatting in portals. And so should have you Phil.

                                • 13. Re: Display a message in an empty Portal
                                  LaRetta_1

                                       Brian, saying "i can't get any options to work consistently" does not provide ANY information.  what did you try and how did it fail?

                                       if you have the text box with transparent background in the portal in the first row and you use:

                                       not IsEmpty ( portalTable::primary key ) 

                                       ... then below go to other options and select text  and set to custom size and 500 not 100 it should work.  If it does not please tell us specifically how it fails.  A screen shot of the entire table in layout mode also helps.  :-)

                                  • 14. Re: Display a message in an empty Portal
                                    brian.curran

                                         Hi LaRetta,
                                    Count (portalTable::Textid) worked fine but when I changed it to not IsEmpty (portalTable::Textid) the "Re-order..." text appeared when it shouln't have done:

                                         The first 10 records I scrolled through each had portal rows so the 'text' didn't display, which was the desired result.
                                         Records 11 and 12 also had portal rows but the message displayed when it shouldn't have.
                                         Record 13 had blank portal rows and the message was displayed correctly.

                                         Mixed results like the above continue throughout the records with no consistency...

                                         Brian.

                                    1 2 Previous Next