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.
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.
Try placing the layout text outside the portal. Does it now work?
No, it's now a yellow text box whether the portal row is empty or full...
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.
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...
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. :^)
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...
So..., do I need to change anything? :)
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.
Thanks Phil, I couldn't get any of the options to work consistently so have reverted back to the Count ()
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.
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. :-)
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...