Selected Record - Wrong Record

Version: 7.4.8 - build 2046
Smart Client

One of our customers is having a problem that we are unable to explain or duplicate. We show a list of Order records using a table view with labels in each row. When the user double-clicks a label, the following code is used to show the selected record (highlighted row) in a modal edit window. The table view form and edit form use the same table.

    var currentIndex = controller.getSelectedIndex()
    
    foundset.getRecord( currentIndex )
    
    globals.showInModalWindow( 'window_orders_edit', 'Orders: Edit', false, false, 'orders_edit' )

Occasionally, when this customer double-clicks on the selected record, a different record is shown in the modal window, and, it is the first record of the foundset (depending how the foundset is sorted by the customer). The customer edits the record only to later discover it was not the intended record and are, to put it mildly, annoyed.

On the Servoy server, we updated the sequences and restarted the server, but the problem persists. I contacted other non-related customers to see if they are having the same issue, and they are not. The customer having the problem is using an SQL cluster while the other customers are using a dedicated SQL server (just an observational difference).

Any help and/or suggestions appreciated!

When for some reasons the foundsets of the two forms are no longer the same, this is very likely to happen. You should make sure your edit form uses the same foundset as the table view by issuing something like

forms.window_orders_edit.controller.loadRecords(foundsetOfTableView)

before you show the edit form.

and: why are you doing this

var currentIndex = controller.getSelectedIndex()
foundset.getRecord( currentIndex )

This doesn’t really do anything, does it?

Thanks for the idea, Patrick! I have implemented your code…hopefully, that fixes the problem.

and: why are you doing this

Code: Select all
    var currentIndex = controller.getSelectedIndex()
    foundset.getRecord( currentIndex )



This doesn't really do anything, does it?

Ha! It doesn’t! I wrote this code about 8 years ago when I was first learning Servoy (version 3). I have no idea if it was my own creation, came from sample code, gleaned from the forum, etc. It’s been removed. Good catch!