# Selected Record - Wrong Record

**URL:** <https://forum.servoy.com/t/selected-record-wrong-record/18924>\
**Category:** Classic Servoy\
**Created:** [July 21, 2016, 9:59pm UTC](https://forum.servoy.com/t/selected-record-wrong-record/18924 "2016-07-21T21:59:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)\
**Post date:** [July 21, 2016, 9:59pm UTC](https://forum.servoy.com/t/selected-record-wrong-record/18924/1 "2016-07-21T21:59:26Z")

</div>

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.

```auto
    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!

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 22, 2016, 7:38am UTC](https://forum.servoy.com/t/selected-record-wrong-record/18924/2 "2016-07-22T07:38:49Z")

</div>

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

```auto
forms.window_orders_edit.controller.loadRecords(foundsetOfTableView)

```

before you show the edit form.

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [July 22, 2016, 7:40am UTC](https://forum.servoy.com/t/selected-record-wrong-record/18924/3 "2016-07-22T07:40:01Z")

</div>

and: why are you doing this

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

```

This doesn’t really do anything, does it?

---

<div class="post-metadata">

**Author:** ![kwpsd](https://avatars.discourse-cdn.com/v4/letter/k/bb73d2/32.png) [@kwpsd](https://forum.servoy.com/u/kwpsd)\
**Post date:** [July 22, 2016, 4:32pm UTC](https://forum.servoy.com/t/selected-record-wrong-record/18924/4 "2016-07-22T16:32:13Z")

</div>

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

```auto
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!
