I take it from the way you phrased the question that you're looking for a way for the user to be able to input new records, rather than an automated record creation method. Here are a couple of thoughts:
1) If you want to prevent a portal from resetting, uncheck "Reset scroll bar when exiting record" in the Portal Setup dialog. That will leave the user where he was when you left.
2) If by "ugly", you mean the fact that you go from maximized to restored inside the application window on Windows, it seems you could insert a script step to Adjust Window [ Maximize ] when you return to the parent layout, could you not?
3) If you want to have the user create a new record without leaving the current context, have you looked at using a single-row portal that shows all the information the user would need to enter in a large panel? This would allow you to create the new record (via a script) and then place the cursor into the appropriate location where the user could enter the information, thus avoiding the need to switch layouts at all. I believe you should be able to do so without committing the record, thus avoiding the screen refresh issues altogether.
Just a few ideas.
The cleanest way to handle very-temporary Go To Layout steps to be on the correct base-table for things such as scripted record creation is to have a blank layout for each base table somewhere in the file, but not visible in the layout menu. It should be set to Form View Only to avoid issues with caching in lsit view, and it can have some simple text block centered on it saying "Please Wait... script in progress".
Switch to the correct one of these layouts for the base table you need within the script. If it appears to the user, no harm done, just a brief message that goes away quickly, leavng the user with the feeling that something expected was actually being done correctly while they watched.
If you use freeze window before leaving the window you start the script from any subsequent changes of layout driven by the script will not be apparent to the user.
for a long time I have relied on the "Magic Key" technic described best by Kevin Frank here. And in the past year or so I added SQL statements (using a plugin) to perform tasks on tables out of context, like creating and updating records.
Hope this helps.
Excellent, Ronnie. Ray Cologon covered this during his "Processing In Place" presentation at DevCon last year, but I'd forgotten about it. Perfect!
Thank you all for the great suggestions!
I was really searching for the last 2 options.
I'm going to try them!
An alternate method is a off screen window say Left = -5000. Then the user doesn’t see the thing, so ugly is not exposed to the user.
Another alternative is an SQL call thru a plugin function (several are available for free), see the ODBC / JDBC guide chapter seven for more information. See the INSERT statement.
But keep in mind that the off-screen window approach is not FM Go compatible, if that will matter.