You can create a related record without using a portal. A simple example would be if you had a table of contacts with address being in a seperate table. If you had a field from the address table on your Contacts layout and you had a match field between the tables as well as "allow creation etc." checked in the relationship graph, then when you entered an address on your contacts layout it would be recorded in the related table. This seems to be something often ignored in these discussions, but it's one of the basic db principles. Sorry if you already know this.
I didn't know that. Might be useful later.
But I was hoping to create the related record from a different layout altogether. Using your example I want to navigate away from the contact layout/table to an address layout/table where I would enter the address and create the related record. I guess I'd need to populate the key field myself, but how?
Set Variable [ $CustID ; Value: Customers::__PkCustomerID]
Go to Layout [Orders]
Set Field [Orders::_fkCustomerID ; $CustID]
Thanks! Works perfectly.
Would I be right in thinking that if I want to simply move to another table without creating a new record then I just leave out line 3 in your script Phil, the New Record/Request script step?
Depends on what you want to do. You would need to either also leave out the set field step or use one method or another to find the correct record to update if you want to modify data in a record of the other table.
So, there is not straightforward way to carry the record ID from one layout to the next? On a single layout one can use a Portal but what if you need more space than a portal allows? Then you need to switch to a second layout connected to the same record. I know there are lots of 'clever' ways to do this, but surely there is a "simplest" solution that is considered best practice for simple databases?
Eg Go to New Layout Maintaining Context ( [Layout 2] ; [RecordID from Layout 1])
where the first argument is the name of the Layout to go to, and the second argument is the identifier used to maintain context.
To quote from my last post:
or use one method or another to find the correct record to update
There are multiple methods possible. One method is to put a button in that portal row that uses Go TO Related Records to make that portal record the current record on a layout based on the portal's table.
Another method is to copy the ID into a variable, enter find mode, change layouts (or open a window and change layouts) to a layout for that table and then use the variable's value to perform a find for that record.