4 Replies Latest reply on Aug 5, 2011 3:07 PM by ShawnPetriw

    Script won't run on second tab



      Script won't run on second tab


      Hey guy!


      I have a script that loops through portal rows and exits after last. I have a table with 2 tabs and an order form on each. The portal on the first tab works fine, the scripts runs through it fine but the second tab's script doesn't. It seems that after the first row it jumps over to the portal on the first tab and tries to run the script down that portal.


      I removed the portal from the second tab, placing it on an empty section of the layout and it worked fine there. Also, when I run it on the second tab then the cursor will end up in the last portal row of the portal on the first tab.


      These are 2 separate scripts that work with different fields so there's no confusion there. Also, on of the first step of the 2nd script is to "go to object" the object being the portal on the 2nd tab. And indeed the first row is always found but then it skips over to the other tab.


      How can I keep the script from leaving the 2nd portal?


      Thanks guys,


        • 1. Re: Script won't run on second tab

          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.

          • 2. Re: Script won't run on second tab

            Hey Phil,


            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) ]

                 New Record/Request

                 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” ]

               End If

              Go to Portal Row [ Select; Next; Exit after last ]

            End Loop



            Let me know what you see and think.

            Thanks so much,



            Edit Note: cleaned up and reformatted script for better readability--PhilModJunk

            • 3. Re: Script won't run on second tab

              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.

              • 4. Re: Script won't run on second tab

                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) ]

                   Duplicate Record/Request

                   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 ]

                End If