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.
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.
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.
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'.
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.