Moving to a particular record

I want to programatically move a form to a specific record, but I don’t want to limit the user to that one record – I want them to be able to use the controller to move back and forth through the foundset from the specific record.

I know I could set the record index, but I don’t know the record index of the record I want to move to.

I know I could use find to get the record I want, but then the foundset is limited to just that record.

How do I do this?

Since 2.1 we have foundset.selectRecord(PrimaryKey); You can use that one to navigate to the desired record. But… The record has to be within the range of records already loaded 200/400 etc. records (if I am correct)…

After that you can do foundset.setSelectedIndex = foundset.getSelectedIndex +/- 1 to go to the next/previous record in the foundset.

what do you know?
the search criteria?
Then you have to do youre search youreself.
and set the selected value
Almost as marcel describes:

foundset.setSelectedIndex(youreIndex)

so a method call not a property
(foundset.setSelectedIndex = youreIndex)

oops :oops:

Actually, Marcel’s answer worked fine.

What I know is the primary key, not the index.

foundset.selectRecord(PrimaryKey) lets me move to the right record, based on the pimary key.

In order to use foundset.setSelectedIndex(youreIndex) I need to know the index – but I don’t know how to get it. If I do a search, I can get to the record, but the recordindex is now changed to the new foundset.

The only problem I had with Marcel’s answer is when the primary key value was not within the 200 record current foundset – and I couldn’t find a way around that. What I had hoped for was the ability to move the user to the right record, but let them still use the controller to move forwards and backwards from there.

In the end, I gave up giving them the controller navigation and I just use search to find the one record they were looking for.

Was there another way to accomplish what I wanted?

how many records can be in that foundset??

you could jump a few times so that you have much more pk’s in mem:

controller.setSelectedIndex(controller.getMaxRecordIndex());

and then do the search again.

I know, but there are over 5,000 records in that table. I didn’t want to grab that much data.

The only reasonable way to do it would be to write my own custom navigation routine that would get the desired record and if they pressed press back or forward then go get that one record for them and so on.

For now, I’m just going to give them the one record they are looking for and not the ability to move forward and backward from there.

gstein:
I know, but there are over 5,000 records in that table. I didn’t want to grab that much data.

The only reasonable way to do it would be to write my own custom navigation routine that would get the desired record and if they pressed press back or forward then go get that one record for them and so on.

For now, I’m just going to give them the one record they are looking for and not the ability to move forward and backward from there.

Would it be possible to navigate to the desired record and then load the previous and the subsequent 99 records, placing the located record right in the middle?

How would you navigatie to the right methods without loading any data? You have to compare something…

Johan… Is there an answer to this? We are up against the same issue. Have a table with 70,000 records. We’re storing the primary key to the user’s ‘last’ record. Need to go straight to that record in detail view on opening the application. If the user clicks a ‘List View’ button, need to go to a list view showing the selected record and allowing the user to step forward and backword through the foundset – which could be any subset of the entire 70,000 records. How do we do this?

This code may be useful to your purposes. In a Show All routine we want to load all records and then return the user to the record they were previously on.

var i = serial_id; 
controller.getMaxRecordIndex();
controller.loadAllRecords();
foundset.selectRecord(i);

Morley…Looking for a way to do this without having to preload all 70,000 records. The time cost is just too high.

if you just have to go the the last one.

“order by XX DESC”

that is the way to go if you want to the last record.
Why whould you see 70K records? A users can’t do anything with such a number.

Brain freeze… I leave for a week and forget the little javascript I know…

I have a foundset on a Form in List View

One of the fields is Customer Name.

How do I go to a specific customer name (stored before the search started in a global) amoungst the numerous rows of my foundset?

Is this some form of request focus I can’t think of right now?

Thanks!

If you want to get a particular record based on a selection then use the function selectRecord from the foundset function.

Step 1: Set a global variable gVarCompany to the PK value of the company you want to select

Step 2: Create a method that selects that record

forms.formName.foundset.selectRecord(gVarCompany);

HTH

Providence1:
Brain freeze… I leave for a week and forget the little javascript I know…

I have a foundset on a Form in List View

One of the fields is Customer Name.

How do I go to a specific customer name (stored before the search started in a global) amoungst the numerous rows of my foundset?

Is this some form of request focus I can’t think of right now?

Thanks!

I’m going to assume you want to retain the current found set and simply jump to the record represented in the global. If you haven’t already, you need to create a relationship between the global and the CustomerName field.

var dupFoundset = controller.duplicateFoundSet(); // store the foundset in a variable
controller.loadRecords(globalToCustomerNameRelation); // jump to the desired record
var i = serialid; // store the record's serial
controller.loadRecords(dupFoundset); // restore the foundset
foundset.selectRecord(i); // jump to the desired record

I believe that will do the trick.

Morley:

It’s been a facinating pleasure to watch your growth over these past months as I’ve gleaned much knowledge from reading your posts.

I have a question about your solution above.

How are you defining serialid? I do not see that function described.

Is there not an easy way to just do something like:

foundset.selectRecord(globals.gCustomerName)

within the foundset I have already created a search for, where the global is the customer name I have predetermined?

Thanks in advance for all your help!

Providence
selectRecord works on Primary Key information, and I think that is what Morley was refering to with his serialid. In the search you run to get the foundset, instead of catching the company name into a global variable, instead catch the PK of that record (serialid or whateve you call it)

HTH

Providence1:
Morley:

It’s been a facinating pleasure to watch your growth over these past months as I’ve gleaned much knowledge from reading your posts.

I have a question about your solution above.

How are you defining serialid? I do not see that function described.

Is there not an easy way to just do something like:

foundset.selectRecord(globals.gCustomerName)

within the foundset I have already created a search for, where the global is the customer name I have predetermined?

Thanks in advance for all your help!

Edward’s post catches it. When I say “serialid” I mean the primary key or “pk” of the table.

About my learning curve it’s been intense. I’ve been on the receiving end of almost all posts on this Forum, it’s a joy to actually have something to give back. :D

I feel that the Servoy docs are still being polished and rolled out. I haven’t gone through them all yet, but Bob Cusick’s tutorial demos are an important contribution. For months I’ve been labouring in frustration getting the FoundSetFilterParam to work. Not only did his tutorial cut through the log jam of misinformation and misunderstanding but also pointed up additional hidden flexibility.

What Servoy have created is truly awesome. Working within it is like having the barn doors kicked open and presented with vast friendly vistas in all directions. Like FMP, Servoy isn’t difficult but there are a lot of neat little techniques to discover. Like the one I shared with you. One of the major advantages of Servoy is this very Forum. The ability to ask questions, simple or arcane, and get prompt detailed answers often with snippets of code, is one of Servoy’s major strengths. It was in a similar exchange that I learned that particular technique. I cherish the chance to pay back.

Kind regards,

Edward:

So is the serailid the primary key field of the foundset table?

If it is, it’s not working:

var i = cuid

Where cuid isthe primary key field for the table whose foundset I’m utilizing.

I’m not sure I understand how to grab primary key information in var i if it is something other the pk field of a table.

Morley:

You’ve expressed my thoughts exactly. I love this program the more I understand it and the more I understand it, the more I want it to do.

I look forward to being able to help others.