5 Replies Latest reply on Sep 9, 2011 10:05 AM by eric

    FM 11 Go to Portal Row by calc ....

    steverothenberg

      Title

      FM 11 Go to Portal Row by calc ....

      Post

      Is there a way to go to a certain portal row based on field contents?

      Portal:

                Field 1     Field 2    Field 3

      row 1: Sunday     blah       blah

      row 2: Monday     blah       blah

      row 3: Tuesday    blah       blah

       

      I want to go to the portal row that Field 1 is "Monday", but it is not always in row 2.

       

      If not possible I have another solution using the same table with differnet relation that produces exactly one record that is "hidden" on the layout. But I would love to find out if this is possible.

       

      THANKS !!!

       

        • 1. Re: FM 11 Go to Portal Row by calc ....
          philmodjunk

          You can use a loop to loop through the records until you reach "Monday".

          You can loop through the portal row with Go To Portal Row [no dialog ; $I ]

          where $I is your loop variable, but I prefer to use Go To Related records to pull up a matching set of related records on a different layout and loop through them there to find the desired record or to use GetNth Record to loop through the set of related records if at all possible.

          Go To Portal Row works on the portal that currently has the focus as there is no way to specify in the step which portal it will interact with. Thus, with two or more portal's on your layout, you have to give them object names and use Go To Object  to put the focus on the correct portal. This can interfere with your user interface and future changes to your layout can break the script more easily than if you don't use go to portal row.

          • 2. Re: FM 11 Go to Portal Row by calc ....
            steverothenberg

            Ya, I thought of that too ! Thought it was kinda brute force, there had to be a more elagant way.

             

            great minds think alike.

             

            What I ended up doing was creating another portal with a relationship that produced only 1 record using the same table. That portal is hidden in the layout so the users dont see it, and the script ends with a "commit" so that the viewable portal updates nearly instantly.

            Yes, I use GoTo object as I have 5 portals on one layout.

             

            thx !

            • 3. Re: FM 11 Go to Portal Row by calc ....
              eric

              I too was hoping someone would have thought of an elegant solution for me here.

              So I'm going to try this:

              If I can get a value list based on the relationship to sort in the same order as the portal, then I can process the results of ValueListItems() to identify the portal row.

              • 4. Re: FM 11 Go to Portal Row by calc ....
                Sorbsbuster

                Eric - I'm not so sure that that will work, or at least it may work only in very particular circumstances.  Maybe I am mis-understanding something.

                For example, let's say you have lots of records covering each day of the week, many times.  The value list based on the portal relationship will only return the unique values, 'Sun, Mon, Tue, etc'.  If the portal's relationship relates to many records, the first 5 of which happen to be a Sunday, then choosing to go to the 1st, 2nd, 3rd - 5th value in the Value List will still hit a Sunday record.

                If your circumstances are that you only ever will have one related record for each day of the week then you will only ever have to 'brute force' through 7 records max, so that's not an issue.  And it leaves you the facility of the portal sort free for another purpose.

                I always worry about putting in a very neat solution that only works in very particular circumstances - Phil's method is very 'robust'.

                • 5. Re: FM 11 Go to Portal Row by calc ....
                  eric

                  You're right. That only works if values in the portal are unique and sorted the same.

                  I don't know why I didn't think to mention List() since I've used it for other things.
                  Again, it only works if the list and the portal are in the same order and if the portal isn't filtering.

                  As it turns out, my portal needs to filter; so none of that worked or me in this case.

                  Since my portal data is sorted on the criteria I'm trying to locate,  I'm trying a variation on Phil's method: Start from the bottom to get the portal row number and do a binary search into the portal.