The "add row" produced when you select "Allow creation..." always appears at the end. What most developers do is remove that option and use a "new record" button that creates the new portal record and this then appears as a blank row at the top of the portal.
Less common, is to put a row of global fields across the top of the portal so that they look like the first portal row and then use a script from a script trigger or button that creates the new portal record, copies the data from the global fields into the new record and then clears the global fields.
Thx for the reply. What Script could I use for the "new record" button? Do i have to make a script where i go to the portal table, add new record, fill in the key_field and then come back to the original layout?
Do i have to make a script where i go to the portal table, add new record, fill in the key_field and then come back to the original layout?
That's the most commonly used and easiest option to set up. But no you don't have to. Its possible to create the new record without changing layouts--which can avoid tripping script triggers and leaves the portal's scroll position unchanged. But the downside is that you have to do some more design work with your database to make it possible.
Here's how to set up a "no layout change" method for adding new portal records without using an "add row" in your portal:
Say your relationship for your portal is this:
LayoutTable::__pkPrimaryKey = PortalTable::_fkForeignKey
To this basic set up, you add a new calculation field to LayoutTable, constNewFlag. Define this calculation by entering the number 1 as the sole calculation term. This field will thus always have the value 1 in all records of LayoutTable.
Add a new field to PortalTable, _fkNewFlag defined as a number field.
Add a new table occurrence for PortalTable to your relationship graph and link it in like this:
LayoutTable::constNewFlag = PortalTable 2::_fkNewFlag
Enable "allow creation..." for PortalTable 2 in this relationship.
Now use this simple script to create a new record in the portal table that is linked to your current LayoutTable record:
Set Field [PortalTable 2::_fkForeignKey ; LayoutTable::__pkPrimaryKey ]
Set Field [PortalTable 2::_fkNewFlag ; "" ]
Set field can only create one new related record in this context and then only if no such related record currently exists. So this script creates that one new related record and then immediately "disconnects" it from that relationship by clearing the key field. Thus another run of this script will be able to create another new record in the portal table.