Go to record from foundset in list

I like to have a method for going to a record in a list from a foundset.
What is the easiest way for doing this?
I know Filemaker has a nice feature ‘Go to PortalRow (select by number)’ for doing this.

Maybe this could also be a feature request for controller.showSelectedIndex() ?

Hi Karel,

Depending on your need there are several ways of doing this.
I will list 2.

  1. Load only the selected record in a form via it’s PK value:
forms.myDetailFromList.controller.loadRecords([relationname.pkField]);
  1. Get the complete related foundset and load that in your form:
var fs = databaseManager.convertFoundset(foundset, relationname);
forms.myDetailFromList.controller.loadRecords(fs);

Hope this helps.

Reading your question again it seems you are asking not how to go to the found set but to just select row x of the related set.
This can be easily done with relationname.setSelectedIndex(index).

Hope this helps.

Hi Robert!

Reading your question again it seems you are asking not how to go to the found set but to just select row x of the related set.

Indeed, but…

This can be easily done with relationname.setSelectedIndex(index).
Hope this helps.

…that’s part of the solution. I’m not only want to select a record, but also view it in a list.

Example: I’m showing a record in a contact detail form. Now I want to see this same record in a listview form.
Suppose I have 400 records in the foundset, only going to the listview form don’t show the record by default in the list.
What I would like to see -when I navigate to the listview-, is to show the record on top of the list, or in the first 10 records or so…

Does this clearify my question?

Hi Karel,

You mean you hit the 200 record ‘limit’.
There is a way around that.
I assume you are using 3.0 so then the following would work:

// Remember the row index
var nIndex = relationname.getSelectedIndex();

// Get the related foundset
var fs = databaseManager.convertFoundset(foundset, relationname);
// Get the prepared statement (SQL) of this foundset
var sQuery = databaseManager.getSQL(fs);
// get the parameters of this prepared statement (SQL)
var aParams = databaseManager.getSQLParameters(fs);

// use this SQL with parameters to get a dataset
var ds = databaseManager.getDataSetByQuery(controller.getServername(), sQuery, aParams, 9999);
// Load the dataset in the form with the listview
forms.myListView.controller.loadRecords(ds);

// select the correct record
forms.myListView.controller.setSelectedIndex(nIndex)

Loading a dataset WILL load all the records at once, not just the first 200 so be careful with large datasets.

Hope this helps.