Selected Record - Wrong Record

Questions, tips and tricks and techniques for scripting in Servoy

Selected Record - Wrong Record

Postby kwpsd » Thu Jul 21, 2016 11:59 pm

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!
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 567
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: Selected Record - Wrong Record

Postby patrick » Fri Jul 22, 2016 9:38 am

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.
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3606
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Selected Record - Wrong Record

Postby patrick » Fri Jul 22, 2016 9:40 am

and: why are you doing this

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


This doesn't really do anything, does it?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3606
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Selected Record - Wrong Record

Postby kwpsd » Fri Jul 22, 2016 6:32 pm

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!
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 567
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA


Return to Methods

Who is online

Users browsing this forum: No registered users and 6 guests