I have to change focus ( to get data from a related table ) in order to populate the fields of the last row of a portal. I use a script triggered by OnRecordCommit on the Name field of the portal row. The parameter passed to the script is the value of the Name field. The script performs a find in the related table and locate the record with the Name value. I then get the data pertaining to the record found.
Before changing focus I saved the portal row number in a variable. When I come back to the original portal, I try to set the fields with the data I obtained from the related table. I go to the row using the saved row number. Then I set fields with the data.
Very simple logic. But I never succeed to populate the right row, the one I quitted. I always get 2 rows, the one I would like to update on which only the Name field is updated and another one that contains all the updated fields I want.
I believe that changing layout has committed the partially updated row and coming back has created a new fully updated row.
I have tried many instances of Go to Portal Row (Last, Previous, By Calculation) without being able to catch the right one.
There is something I am missing.