# onRecordSelection oddity

**URL:** <https://forum.servoy.com/t/onrecordselection-oddity/1778>\
**Category:** Classic Servoy\
**Created:** [April 24, 2004, 10:15pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778 "2004-04-24T22:15:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [April 24, 2004, 10:15pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/1 "2004-04-24T22:15:19Z")

</div>

Not sure this is bus so I’m posting it here. I got two forms based on the same table. On form A there is a tabpanel that displays form B. So far so good.

Now, if i’m on form B and do some record manipulation (show omited, show all, etc) the onRecordSelection method of form A is executed.

It’s not bothering me since I actually don’t use form B directly but wanted to know if it’s normal behavior.

## Ronnie

Servoy 2.0 RC13  
MacOS 10.3.3

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [April 24, 2004, 10:46pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/2 "2004-04-24T22:46:43Z")

</div>

Just noticed similar behavior in this situation:  
form A (record view) and form B (list view) based on same table, form A has a onRecordSelection method assigned but form B does not.

If you select a record on form B, having loaded form A first, the onRecordSelection of form A is executed.

## Ronnie

Servoy 2.0 RC13  
MacOS 10.3.3

---

<div class="post-metadata">

**Author:** ![maarten](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@maarten](https://forum.servoy.com/u/maarten)\
**Post date:** [April 25, 2004, 7:11am UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/3 "2004-04-25T07:11:48Z")

</div>

onRecordSelection is triggered on table level (not on form level).

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [April 25, 2004, 7:45am UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/4 "2004-04-25T07:45:47Z")

</div>

to make it more clear:

foundsets are shared over forms (or you have set yourself a relatedfoundset in the form or you have set the property useSeperateFoundset)

and if you have loaded form A and then go to form B both based on the same table. Then they have the same foundset. So if you are changing the selected foundset in B then A will also change. We have to execute onRecordSelection then for A because if you do something like testing data and on that data you color or set the visibility of elements. Then you expect that when you go again to form A that form A has the right visual state for the selected record!

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [April 25, 2004, 7:29pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/5 "2004-04-25T19:29:32Z")

</div>

Thanks guys, this clarifies things; I have some code editing to do ![;)]( "Wink")

A couple of notes:

1- Maarten’s comment should be included in Servoy’s help under the onRecordSelection definition as a note.

> onRecordSelection is triggered on table level (not on form level).

I’d like it more if it would be on a form level.

2- Is there a way to just load a form without showing it? if not, Servoy could use a controller.load() to make form’s onRecordSelection method available to other forms.

Again, thaks.

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [April 25, 2004, 7:43pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/6 "2004-04-25T19:43:12Z")

</div>

it is on form level…

because the form does get an record selection change… It doesn’t matter that it is currently not showing.. that is not importand..

if you want a form to be there.. then you can call loadAllRecords or loadRecord on it with a foundset..

Then the form is “live” and wil get selection events if it als shares a foundset you are viewing in other forms.

---

<div class="post-metadata">

**Author:** ![r.rios](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@r.rios](https://forum.servoy.com/u/r.rios)\
**Post date:** [April 28, 2004, 3:55pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/7 "2004-04-28T15:55:03Z")

</div>

I’ve solve my problem with

```auto
if(currentcontroller.getName() == controller.getName())

```

on each of my onRecordSelection methods; this insures that only the active form executes it’s method.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![bcusick](https://avatars.discourse-cdn.com/v4/letter/b/ed8c4c/32.png) [@bcusick](https://forum.servoy.com/u/bcusick)\
**Post date:** [July 8, 2004, 6:46pm UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/8 "2004-07-08T18:46:12Z")

</div>

Hi All,

It would be nice if we could specify that the onRecordSelection even run for just this form (i.e. not cascade) as part of the property - rather than having to add code to EVERY SINGLE onRecordSelection method.

Just my $0.02,

Bob Cusick

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [July 16, 2004, 11:21am UTC](https://forum.servoy.com/t/onrecordselection-oddity/1778/9 "2004-07-16T11:21:53Z")

</div>

onRecordSelection always runs just for that form. Where should i run in otherwise??

But in 2.1 only recordSelection will only be fired for the visible form.
