You can add a Freeze Window at the beginning of the script and the fact that you change layouts will not be visible to the user. If there are layout based script triggers being tripped by the change in layouts, there's a way to disable them.
For an alternative approach to deleting portal rows, you can check out the script found in the Known Bugs List database. It's designed so that you can import it error free into any FileMaker file. (The key data specific to your file and layout is passed as a script parameter.)
"Also, I have not enabled the option to allow for deletion of records in the portal as I want this handled by the button and not directly by the user."
What script is attached to the button determines the User experience. There is no need to leave the portal at all - the row they click will be the row deleted. If you wish to display the line being deleted then script it as:
Set Selection[ Task Table::Task Description ; start position: 1 ; end position ; Length ( Task Table::Task Description ) ]
Set Error Capture [ on ]
Delete Record/Request [ ]
You could also use Go To Field [ select/perform ; Task Table::Task Description ] instead of Set Selection.
Thanks for the info, folks!
No one mentioned the easiest idea of all...put a delete button on the portal record and use the Delete Portal Row function found in the Records view in the list on the left.
None of the complicated ideas above are needed to delete one portal row.
I agree, Jack but script is needed instead of button if Rodrigo wants to also highlight the Description as well which is why I provided script Either Delete Record or Delete Portal Row will accomplish the task within a script ... there is no need to go to another layout just to delete a related record.
The subject was 'can I avoid layout switch' and the answer is yes. :^)
I'll have to experiment with your example methods a bit to see which way I like to do it best, but my main goal is to have the user only use the '+' and '-' buttons that I have provided to add and delete tasks. I'm just trying to keep the UI simple and the workflow simplified so that the user doesn't have to learn about "five" different ways to accomplish the same task of adding or removing a record.
Thanks again for your input!
The button ON the portal row with Delete Portal Row is the easiest.
If the user wants to see the actual record BEFORE deleting it then use
GTTR related record (select your layout) in a new window.
The delete button script will then be
To simple for words...
If they con't want to delete the record then a Cancel button would be
Both closes take you back to the original record.
12 now lets you select a modal window which prevents some of the new window all over the place features.
The main problem with a straight forward, unscripted delete portal row is that it can be cryptic to the user. "Master record", "Related record"????
I prefer a system where actual data from the selected portal row is displayed in the confirmation dialog and with the portal row highlighted for additional confirmation. Since I've been able to set up a script that will work with any layout in any file, this took some work to set up originally, but is now very easy to implement anywhere I need a delete portal row script.
Jack said, "The button ON the portal row with Delete Portal Row is the easiest."
That is what we are talking about, Jack - the delete script button MUST be on the row or else you must capture the ID and go to the other layout to delete it. Usually an Add button is placed above the portal but the delete is within the row.
Now YOU are making it more complex than it need be, LOL. Delete Record and Delete Portal Row both provides dialog allowing User to cancel - just as I showed on my Delete Record ... nothing inside the brackets means that it does not 'perform without dialog.'
There are many approaches here which work.
To capture the ID of a portal row you have to click on it, right?
So click on the row, click a button, etc.. kinda the same.
Now if you DON't want to immediate delete the row (using a Delete Portal Button on the Portal Row) and instead want to LOOK at the record before deleting it, then just use the GTTR button I mentioned above which takes you to the layout WITHOUT COMPLEX SCRIPTING...
Sometimes we get so wrapped up in SCRIPTING we forget how easy it could be... :)