Why do some people concentrate on worthless principles like "I am trying to minimise layout switching" , roflmao, instead of concentrating on maximising the very goal they have, i.e. making a specific routine happen (1) as fast as possible, (2) successfully ?
If you have been given the same clue from different people and you insist with your obsession, dismissing their experience and advices as being worthless, then go your way and don't waste our time, waste yours.
(and learn to use Freeze window, for God's sake)
Go to Object [ portal object name ]
Exit loop if [ isempty ( related primary key) ]
Is that your kind way of saying there is no other way of doing this?
Sorry, we are not all as brilliant as you!
there are many ways of doing it, but that's not the point.
The point is doing it the fastest and most efficient way. You decided that switching layouts is a bad idea and are dismissing solutions based upon this, it's your choice, have fun with it.
I've simply asked if there is another way to do this. I am not suggesting as better.
You can also (in a script) do the following: go the related records in a new window, name the window "delete records", windows position -10 vertical, height 10.
Delete the records and close the window "delete records".
Then you stay in your layout.
Is this something acceptable?
I will try that. Thank you karina!
I'd say your three best options are 1) Freeze Window, Switch to different layout, Find those records, delete, return (as others have mentioned), 2) Loop through the records in the portal, deleting each record one by one, 3) If the file is served, create a Perform Script on Server script which will delete the records.
Opening a New Window, finding those records and deleting will work, but with Go and WebDirect, I personally have been opening utility windows less than I used to.
If your file is on a server, the fastest method would be to identify all of the id's of the records in the portal, then PSOS to find the records and delete them, and update your portal after the PSOS is done. Be careful. Plus, if you're only deleting a few records, the faster speed wouldn't really matter much.
Second, I'd go with switch, delete, return. If you switch to a Form layout (as opposed to List) with no fields on it, the switch would be fast, no unstored calcs would be involved, you wouldn't be downloading elements you don't need, and indexes would update AFTER the delete, so speed would be good.
Third, I'd loop. It's workable, but slower, I'm guessing.
So...pick your poison. For that matter, your script could calculate the number of records in the portal, and could delete them all using whichever method made the most sense for the situation. E.g., 1 record in the portal, just go to the portal and use delete portal row. 2-10, loop (maybe). Over 10, switch to layout and come back. Over 20, do it on server.
Lots of options.
One other thing... don't forget to consider whether or not you're filtering the portal. If you're using a filtered portal, and you JUST use GTRR then delete all the records...you'll delete filtered records that weren't DISPLAYED IN the portal but WERE related.
So...Use something like:
Go to field PortalTable::FieldA
Go to Related Records ( using layout based on PortalTable, Match current record only ).
Test first, on a backup, or with a debugger on and the delete record step disabled until you're sure you're seeing what you want to see.
why not just write the script to do it the fastest best way and PSOS?
I completely agree.
Another - probably faster - approach is to "pre-delete" the portal rows, see attached.
A night-time script running on the server can clean up the pre-deleted rows by doing a find empty fk in LineItems and deleting them for good.
Thank you for the suggestions. I have gone with the alternate layout with the freeze window, which I didnt realize existed. Glad I asked. Thanks for the sample siplis, I will definitely be able to use.