1 2 Previous Next 21 Replies Latest reply on Mar 14, 2013 7:46 AM by themonman

    Go to next portal row not working

    themonman

      I'm trying to create a script to copy the values from a field from all rows in a portal into a "local" field.

      Here's my script:

       

      Enter Browse Mode

      Go to Record/Request/Page

      [ First ]

      Loop

      Loop

      Go to Related Record [ From table: “TATConfig”; External; Using layout: “TATConfig” (TATConfig) ] [ Show only related records ]

      Copy [ TATConfig::Order_Code ] [ Select ]

      Paste [ TATproducts::Config_Sort_Order_Code ]

      Insert Text [ “ ” ]

      Go to Portal Row [ Next; Exit after last ]

      Exit Loop If [ TATConfig::Order_Code= "" ]

      End Loop

      Go to Record/Request/Page [ Next; Exit after last ]

      End Loop

       

      The problem is: The script doesn't go to the next portal row. It just keeps repeating the Paste command from the first portal row in an endless loop.

       

      Filemaker Pro 8.5 Advanced.

       

      Any suggestions?

      Thanks!

        • 1. Re: Go to next portal row not working
          BruceRobertson

          It will be better to start at the beginning and explain what you are trying to do.

          And upload a copy of your file if possible.

           

          There are a couple of less-than-best-practices going on here.

           

          There are other ways to collect data, and copy/paste operations are generally unnecessary and a bad idea in scripting. You don't want to mess with the user's clipboard.

           

          The preferred operation is set field.

           

          Usually it is also a good idea to avoid walking portal rows.

          • 2. Re: Go to next portal row not working
            Malcolm

            I'm trying to create a script to copy the values from a field from all rows in a portal into a "local" field.

             

            The problem is:  The script doesn't go to the next portal row. It just keeps repeating the Paste command from the first portal row in an endless loop.

             

            You are losing your place in the portal because you are using Go to Related Record. It isn't necessary to do that. All the data is available to you from your location "in" the portal row.

             

            malcolm

            • 3. Re: Go to next portal row not working
              DavidZakary

              Check your portal settings - it it set to "Reset scroll bar"?

              • 4. Re: Go to next portal row not working
                Malcolm

                BruceRobertson wrote:

                 

                Usually it is also a good idea to avoid walking portal rows.

                 

                What's your reasoning Bruce?

                • 5. Re: Go to next portal row not working
                  debi

                  Themonman,

                   

                  Have you checked out the List function? You may be able to do this without a script at all. The List function can return all related values in a return-delimited list; if you want the values separated by something else, you can wrap List inside a Substitute function.

                   

                  HTH,

                   

                  Debi Rubel

                  FullCity Consulting

                  • 6. Re: Go to next portal row not working
                    BruceRobertson

                    Why avoid walking portal rows?

                     

                    With effort, it can be done. But when would you really need to? As Debi mentions, you can use function such as the list function to read the data directly.

                    Are there multiple portals - are you walking the RIGHT portal?

                    Are the fields you want to deal with on the portal?

                    Are you sure that at some point you didn't perform an operation that takes you away from the portal - and if so, did you design your script to navigate reliably back to the row you left?

                     

                    These things CAN be managed; but it seems to me that mostly you don't need and you get more reliable results if you use other methods.

                    • 7. Re: Go to next portal row not working
                      Malcolm

                      Have you checked out the List function? You may be able to do this without a script at all. The List function can return all related values in a return-delimited list; if you want the values separated by something else, you can wrap List inside a Substitute function.

                       

                       

                      Be very careful using List in this way. List does not return missing values. If you have seven records in the portal and three have an empty field you end up with a list of four items. You do not know which records those four items came from.

                       

                      It would be desirable to have a function similar to list which returned an item for all records, including empty values.

                       

                      Malcolm

                      • 8. Re: Go to next portal row not working
                        Malcolm

                        Why avoid walking portal rows?

                         

                         

                        With effort, it can be done. But when would you really need to? As Debi mentions, you can use function such as the list function to read the data directly.

                         

                        Dangerous. You must use list with caution. The relationship between the array of list values and the portal rows is coincidental. An empty value in a field will throw the list out. A value that contains a carriage return will throw the list out.

                         

                        Are there multiple portals - are you walking the RIGHT portal?

                         

                        Agreed. Go to Object allows us to be specific

                         

                        Are the fields you want to deal with on the portal?

                         

                        They don't need to be on the portal. They only need to be accessible via the valid chain of related tables. If the table is accessible the fields are accessible.

                         

                        Are you sure that at some point you didn't perform an operation that takes you away from the portal - and if so, did you design your script to navigate reliably back to the row you left?

                         

                        We saw that in the script above. Although walking the portal is often done to avoid navigating to other layouts to walk the record set there are still cases where we need to leave the portal. It's necessary to record the active portal row number and on return, go to object[name] and go to portal row .

                         

                        These things CAN be managed; but it seems to me that mostly you don't need and you get more reliable results if you use other methods.

                         

                        I've never known the method to be unreliable. It has lots of positives: It is a good, fast method. The portal is an implicit filter so it can reduce the need for extra scripting to locate data sets. Portal Filters can be added to control the list of records in interesting ways. Often, you don't need to leave the layout so there is less need to maintain the screen/tab/user state.

                         

                        Malcolm

                        • 9. Re: Go to next portal row not working
                          themonman

                          debi wrote:

                           

                          Have you checked out the List function? You may be able to do this without a script at all. The List function can return all related values in a return-delimited list; if you want the values separated by something else, you can wrap List inside a Substitute function.

                          The List function was a good idea, but when it created the list, it also sorted the list (alpha sort).

                          I want to keep the list in the same order as the rows in the portal.

                          Any way to do this?

                          • 10. Re: Go to next portal row not working
                            themonman

                            DavidZakary wrote:

                             

                            Check your portal settings - it it set to "Reset scroll bar"?

                            I tried it both ways... no difference.

                            Are you saying Reset scroll bar should be checked, or not checked?

                            • 11. Re: Go to next portal row not working
                              debi

                              Thmonman,

                               

                              Yes, you have some control over the List function's sort order: make sure the table occurrence you are using for the function is sorted the way you want it (in the relationship graph), instead of relying on the sort feature associated with the specific portal.

                               

                              Debi Rubel

                              FullCity Consulting

                              • 12. Re: Go to next portal row not working
                                themonman

                                Malcolm wrote:

                                 

                                You are losing your place in the portal because you are using Go to Related Record. It isn't necessary to do that. All the data is available to you from your location "in" the portal row.

                                 

                                malcolm

                                OK, I tried it without using Go to Related Record. I also tried Go to Object and then Go to Portal Row.  It's still going into an infinite loop... still losing its place in the portal.

                                 

                                Anything specific I can try to "stay" in the portal, while I set another field's value?

                                • 13. Re: Go to next portal row not working
                                  BruceRobertson

                                  Back to the question.

                                   

                                  What is the PURPOSE of this script? What are you trying to do?

                                  • 14. Re: Go to next portal row not working
                                    BruceRobertson

                                    You should re-post your entire script (or better, the file) if you really want effective troubleshooting.

                                    1 2 Previous Next