I have a portal which permits new records to be added, but in some cases I don't want the "add new portal row" option on the bottom of the portal row. Is there some way to filter these out? I tried checking to see if primary key = "" but it didn't seem to filter it out when I did that.
You won't be able to hide the row itself. What you can do is hide the objects in the row using the "hide when" calculation. isempty( primary key ) or isvalid( primary key ) will both work.
OK yeah, that's what I've been doing. The hide statements start to get complex because there are other criteria where it might be hidden. I think I might just make a second join without add capability. Thank you!
How about the other way around? Disable the relationship's ability to add records, then add a button that does all the work of adding a portal row by going to the table's layout, creating a record, then returning to the original layout (or something similar). You would then only need to display or hide the button.
Perhaps you can do something like this for your hide calc:
IsEmpty ( RelatedTable::foreignKey ) or ( <your original hide calc> )
Then when you want to create a new row you can follow @bdbd 's suggested UX workflow and when a user clicks "+" do something like:
Go to Object [ "MyPortal" ] Go to Portal Row [ Last ] Set Field [ RelatedTable::id ; Get ( UUID ) ] Go to Field [ <field in portal row> ]
That should make the fields appear for data entry (as long as your hide calc doesn't hide them in that case)
Adding to the above suggestions, you can even put a second portal just above the display one with just one row and create new entries there so it is always at the top.
If you have multiple objects with independent hide conditions, you can group the objects and then add a single hide condition to that group.
That's a great trrick but you have to remember to hide the row as soon as the record is committed which you do in the portal filter. Personally, I use a calc number field with a value of 1 and use that to test whether a record is valid or not.
I was going to suggest this. It is my preferred way.
hi @jfletch, glad to see you here
How simple it would have been for FM to add a checkbox option (similar to the existing delete row option) in the portal setup to allow adding rows through the portal. I'm sure it is just a holdover from FM 2 or 3 (or whenever the portal object was introduced), but it would really have reduced the number of TO's over the years.
And scriptable control of the setting!