Page 1 of 1

Selected Record - Wrong Record

PostPosted: Thu Jul 21, 2016 11:59 pm
by kwpsd
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.

Code: Select all
    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!

Re: Selected Record - Wrong Record

PostPosted: Fri Jul 22, 2016 9:38 am
by patrick
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

Code: Select all
forms.window_orders_edit.controller.loadRecords(foundsetOfTableView)


before you show the edit form.

Re: Selected Record - Wrong Record

PostPosted: Fri Jul 22, 2016 9:40 am
by patrick
and: why are you doing this

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


This doesn't really do anything, does it?

Re: Selected Record - Wrong Record

PostPosted: Fri Jul 22, 2016 6:32 pm
by kwpsd
Thanks for the idea, Patrick! I have implemented your code...hopefully, that fixes the problem.

Code: Select all
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!