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.
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=11, Global=63, Global =525
I would then be able to build a filter based on selecting for the lefthand >= to global and < Global, for the righthand >= global and < Global.
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 to < global and Right hand >= Global to < global
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.
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.