In the Loop Through Grid, after the InvoiceLine has been created, I'd create the relationship table record based on the SalesOrderLine RecordID and the InvoiceLine RecordID.
But like I mentioned, that would only sort of get me there because when creating a fully custom table I can't define relationships in there with other tables, no referential integrity.
I think what I'm going to have to do, since I can't put real lookup fields in a grid which is what I'd need to do otherwise, is abandon the idea of referential integrity. Create two new fields in InvoiceLine: one for the SalesOrderLine RecordID, just so I can see a real flow if I want to, and one for the SalesOrder PONumber. Get the PO number before the CreateInvoice screen pops up, get the SalesOrderLine RecordID when I'm traversing the grid in the CreateInvoice screen and insert both of those data into the InvoiceLine table when the InvoiceLine records are being created.
Doing that will also mean I'll need to setup some kind of additional constraint around actions related to the PONumber field in the Sales Order screen; if someone changes the contents of that field after the InvoiceLine records are created, when the Sales Order is saved should it cascade that change to the InvoiceLine records? Or should that change be something the user is notified of when they enter an already saved Invoice where the Sales Order corresponding to the InvoiceLine records in that invoice no longer has the same "InvoiceLinePONumber" as the Sales Order PONumber?
Some things I'll have to consider.