The user is showing just a handful of records. They click a button for Show All.
Currently I’m using loadAllRecords() which jumps the user to the first record. I’d like to leave the user in the same record they started from – the same behaviour of FMP’s GTRR function.
I don’t believe Index functions would work in this situation. All the Load functions load a particular set of records, not simply go to it. Puzzled.
jcompagner:
What does exactly happen when the user presses twice (as fast as the user can do that or always the second time??)
Nothing whatever appears to happen on the first click.
Have yet to devise some traps to see if something might be calculated or the current record is changed in some way on the the first click. But loading all records definitely does NOT happen. One other test I plan later today is to include the string of code twice in the same method, see if that does something. Obviously the first click accomplishing something essential, but I can’t as yet guess what that might be.
The second click accomplishes the goal – load all records and keep the user on the record they were on at the beginning of the process.
jcompagner:
are you sure that the method call is triggered?
Yes, it’s triggered.
Added “application.output(‘comDetails.showAll’)”, the name of the method as the first line. I got back the output but the problem still manifested – failure to execute completely on the first click, success on the second.
Then I added some more “application.outputs” to see even more closely what’s going on, see below. To my utter amazement, by adding these new outputs to the debugger the routine executes properly on the first click.
I’ve isolated it to the first call to calculate the controller.getMaxRecordIndex()
Here’s my current code that works on the first click. The recordStatus() call is to a method that sets a global to display text similar to “7 of 27” – the current record number and the total in the current set.
// application.output('comDetails.showAll');
var max1 = controller.getMaxRecordIndex();
application.output('max1 = ' + max1);
var i = company_id;
application.output('i = ' + i);
controller.loadAllRecords();
// var max2 = controller.getMaxRecordIndex();
// application.output('max2 = ' + max2);
foundset.selectRecord(i);
recordStatus();
Any chance you could post a solution which demonstrates this ?
Harry
Hi Harry
By modifying my original code from:
var i = company_id;
controller.loadAllRecords();
foundset.selectRecord(i);
to:
var i = company_id;
controller.getMaxRecordIndex();
controller.loadAllRecords();
foundset.selectRecord(i);
the problem is solved.
If you don’t need the line “controller.getMaxRecordIndex();” to make the routine work but I do, here’s one possible explanation. The original button is on a custom controller which then calls the script above on the currently displayed tab panel.
That sort of works. It would give me records 1…200 (or whatever the current found set it) and then record 15,001 (current record). What I’d like is to be on record 15,000 and have the found set of records be 15,001…15,200 (default row order in the table).
I know, I know…it’s a Filemaker thing… embarrassed
Oyi! I had a LONG conversation with a fellow SAN member about this over the past couple of months. There is a way to do it - but it is SO cumbersome and has to be called from SO many places SO often, that it’s just not worth it.
You would basically have to select the pk from current PK + 200:
var query = "select pk_id from customers where pk_id >= " + pk_id + " AND pk_id <= " + (pk_id + 199)
Then - have a nice day if the founset is sorted! All bets are off. You can sort the set after selection… there are other issues as well.
Don’t know if this helps, especially if your DB doesn’t support the functions, but some DBs will use the TOP option and others, like MySQL will have the LIMIT option. I haven’t worked with Oracle, and I’m not sure - just a guess here - but, I hear there is a BETWEEN option as well?
If the DB supports subqueries you can do something like this.
SELECT TOP 20 *
FROM Table TableName
WHERE TableName.Column1 NOT IN (SELECT TOP 10 Column1 FROM TableName) – Returns the second set of 10 records.
Otherwise you’ll have to do some record looping or what Bob suggests with defining the range in a SQL query - and, of course, getting them back within a sorted order is, like Bob says, another story!
Any chance that the LoadAll() function could have an optional parameter to load all and stay on the current record? This is exactly what happens when you click on Show All in the menu. Would be nice if that was available via a method, without addititional coding.
that is not something showAll from the menu does,
we always are trying to do that. Are you sure that it doesn’t work for the same situation of the same founset when going through the menu or doing it through a script?
Do remember if the selected pk suddenly is outside the first 200 it will fail. Because we will not search indefinite.