Does anybody know of a technique to determine if you are on the last portal row? I mean in the current sort for the layout that you are on. Thanks
You could try:
Get ( ActivePortalRowNumber ) = Count ( relatedTable::relatedID )
if the relationship does not allow record creation, or
Get ( ActivePortalRowNumber ) = Count ( relatedTable::relatedID ) + 1
if it does.
Good calculations suggested above.
You can also use the "Last" function, which might be quicker than a Count. For example, comparing the Last value in the portal for a specific field to the exact same field within your active portal row.
Also, you could use a script step to try to go to the next portal row and see if it returns an error.
I'm sure there are probably many other techniques as well.
Not sure that helps in the case where the portal allows record creation. Last returns the last non-empty value, and if you just use relatedTable::relatedField = Last ( relatedTable::relatedField ), you'll miss that use case. You could cover it by using IsEmpty ( idField ). (No value because the record doesn't exist.)
But yes, avoiding the aggregate is good if you can.
Note also that Last functions regardless of whether the focus is actually in the portal - so you could wind up with a false positive if you don't otherwise verify the focus.
What you describe applies equally to Count as long as you use Last on a field that's never empty. And you would not set the focus, just specify the appropriate relationship for the portal in question.
And watch out if the portal should happen to be filtered...
But Get ( ActivePortalRowNumber ) solves the focus issue. The OP's question was about the active portal row, yes?
And yes, a filtered portal will cause issues.
As usual all the answers are a wealth. What I am actually trying to do is make something visible when it is on the last row of a portal with Behavior -> Hide object when in the Inspector. When it is on any row but the last I want it not shown. Thanks
A good solution I found is to create a field that is a summary (running) in the table that the portal is showing. Then you can use the Behavior -> Hide object when- to say when the Summary Field in not equal to the count of primary keys something like so.
TABLE::summary_portal_count ≠ Count ( TABLE::primary_key )
If your use case is for showing an object only in the record-creation row, set the Hide When to
NOT ISEMPTY (related_ForeignKeyField)
Then the object will disappear in populated portal rows.
Stephen Huston wrote: If your use case is for showing an object only in the record-creation row, set the Hide When toNOT ISEMPTY (related_ForeignKeyField)
Stephen Huston wrote:
Probably the best solution.
I love your simple solution @Stephen_Huston.
I will now go through the entire solution and hide all the "garbage bins" on the "create new" rows in all portals. Using the simple calculation IsEmpty(RelatedTable::KeyField).
Widt best regards Magnus Fransson.
That is a good solution for that, I have used it before. For this case, I need something that shows for the portal stretching once it creates a scroll bar. To be clear, I mean if I have less than six entries in this portal the display is fine, but after 6, there is no way to see the portal boundary. So I want this to show up if the count is more than 6. Thanks a lot!
Thanks to everyone for giving input and answers.
Retrieving data ...