3 Replies Latest reply on Jun 3, 2012 9:59 PM by philmodjunk

    Stepping through mutiple portals



      Stepping through mutiple portals


      I've built a layout that will allow me to see a maximum of 44 rows in two portals 1-22 in the lefthand one (named portal_l) and 23 - 44 in the righthand one (named portal_r) in the screen shot you will see I have added two buttons [Next] and [Previous], I would like to have a script behind the Next button, so that when it is clicked, the start row for each of the portals is incremented by 22, so that the contents of portal_r move to portal_l and the next 22 records appear in portal_l, (and obviously I'd then do a decrease by 22 with the [Previous] button.

      I can't find anything on reseting the initial row attribute by scripts.






        • 1. Re: Stepping through mutiple portals

          You can't reset the portal's initial row from a script.

          But you can manipulate a portal filter to display different sets of records.

          Consider this portal filter expression:

          Let ( [ First = Max ( Parent::gStartNumber  ; 0 ) ;
                    Last = Min ( Parent::gStartNumber + 3 ; Count ( Child 2::ID ) )
                  Child::ID ≥ GetNthRecord ( Child 2::ID ; First )  and Child::ID  ≤  GetNthRecord ( Child 2::ID ; Last )

          Child is the portal table occurrence and Parent is the layout's table occurrence.

          gStartNumber is a field defined in Parent as a global field.

          You need two identical relationships from parent to Child in order for this to evaluate correctly. Child2 is used in the filter expression and Child is used in the portal and the filter expression. (Using getnthrecord on the same portal that you are filtering doesn't work.)

          The assumption here is that ID is an auto-entered serial number and the records in the portal are either unsorted or sorted in ascending order by ID.

          To get a smooth portal update I included gStartNumber in the relationship to Child with the X operator.

          • 2. Re: Stepping through mutiple portals

            Thanks for the suggestion but I think my issues might be more complex than this (my fault not yours), I do have an ID field but this wouldn't be used in the sorting process, competitors can come in in any order so I would need in effect to be able to sort the portals either by their competitor number, or by the time they arrive.

            As in normal situations competitors only come through once, I thought I might look at using a filter based on a repeating global field (in the parent table), this would be populated by looping through the child table record by record, having first sorted it as needed and either contain the competitor number or time (dependant on the sort selected) for every 20th record (my portals would still be 22 long just incase any competitor got lost and pass through the checkpoint twice.

            Using the data in the screen above the global entries would be Global[1]=11, Global[2]=63, Global[3] =525

            I would then be able to build a filter based on selecting for the lefthand >= to global[1] and < Global[2], for the righthand >= global[2] and < Global[3].

            To do my next and previous buttons, I was thinking of having a 'bias' global value, which would initially be 0, so I would have the filter as

            Left hand >= Global[1+bias] to < global[2+bias] and Right hand >= Global[2+bias] to < global[3+bias],

            so when bias is 0 it is the same as normal, where as when I click on Next bias would be increased by 1

            Left hand >= Global[2] to < global[3] and Right hand >= Global[3] to < global[4]

            I have now done this successfully (much to my amazement as I've only just started playimg with filemaker), but have one problem, and this is that my script that loops through the child table won't work when run from the portal screen ( i understand this in that the Parent Table only has one record...) At the moment I have to go first to a layout based on the child table so the script can loop through the table and then go back to the portals layout, how can I get the script to run from the portal layout, and loop through the child records rather than having to go through the layout based on the child table.



            • 3. Re: Stepping through mutiple portals

              Generally, I avoid looping through portal rows. I prefer that my scripts freeze the window, pull up the portal records on a layout based on the portal table, loop through them (or whatever I need it to do with them), then return to the original layout.