I suggest posting your script.
If you have filemaker advanced you can copy and paste your script from a database design report.
If you don't you can print the script to a PDF and then copy the text from the PDF and post it here.
Here you go:
Set Variable [ $$orderid; Value: order:: orderID ]
Go to Object [ Object Name: "binsportal" ]
Go to Portal Row[ First ]
If [ not IsEmpty (all bins::add to cart) ]
Go to Related Record [ From table: “all bins”; Using layout: “INV BINS” (bins) ] [ New window ]
Set Variable [ $binid; Value:bins::ID box ]
New Window [ Name: "Add bin to lineitems"; Height: 100; Width: 100; Top: 0; Left: 0 ]
Go to Layout [ “lineitems” (lineitems) ]
Set Field [ lineitems::binID; $binid ]
Set Field [ lineitems:: orderID; $$orderid ]
Set Field [ lineitems::REQUESTED for job; 1 ]
Close Window [ Current Window ]
Perform Script [ “2 magic BIN portal loop” ]
Go to Portal Row [ Select; Next; Exit after last ]
Let me know what you see and think.
Thanks so much,
Edit Note: cleaned up and reformatted script for better readability--PhilModJunk
THere's parts of that script I don't follow as you didn't post the second script and I can't tell from your script what layout you are one when the script starts, but I suspect you need to add a "go to object" step just before Go To Portal Row. I'm guessing that the layout changes and new windows are moving the focus off the portal and nothing in your script moves it back.
Note: It's often a simpler script to use a find or go to related records to pull up the records in a portal on a different layout and loop through them there instead of interacting with the portal. You can freeze the window, switch layouts to process the loop and then switch back. Some times you have to use Go to object to select the same tab you started on, but it's still a simpler approach in most cases.
I had a similar problem and found a solution that works for me.
I have a job tracker database with 5 tabs, 2 of which have portals.
Each of them simply add a list of items for a production run (t-shirts on one tab, embroidery on the other)
I have a script that duplicates the selected portal row to easily add items to the run list (like the same style shirt, but different size).
But to keep the tab control working properly, I needed to select a field in the last portal record. This worked fine for Tab 1, but when the script runs with Tab 2 active, it jumps to the portal in Tab 1, pretty much as described above.
What I did was add a script step for each of the two scripts to "Go To Object"
I gave the first field in the portal of Tab 1 an object name, and the first field in the portal in Tab 2 another name.
Each duplilcate script duplicates the portal row, THEN goes to the object, then goes to the last portal record.
This appears to give the "go to portal row" the proper context. It would seem to me that the tab layout alone should give the context, but this is the solution I needed to get it done.
I hope this helps you.
If [ IsEmpty ( DTG_ORDER::dtg_ID ) ]
Exit Script [ ]
Go to Related Record [ From table: “DTG_ORDER”; Using layout: “DTG_ORDER” (DTG_ORDER) ]
Go to Layout [ original layout ]
Perform Script [ “proper_tab” ]
Go to Object [ Object Name: "DTG_style" ]
Go to Portal Row [ Last ]
Go to Portal Row [ Previous ]