# How to figure out if a related foundset was in find

**URL:** <https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677>\
**Category:** Classic Servoy\
**Created:** [September 16, 2011, 1:15pm UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677 "2011-09-16T13:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [September 16, 2011, 1:15pm UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/1 "2011-09-16T13:15:31Z")

</div>

Hello,

I have a related foundset and maybe perform a find() in it. Is there a way to figure out if that foundset is just plain related or further filtered?

Currently I see no way…

Thanks  
Patrick

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [September 19, 2011, 6:50am UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/2 "2011-09-19T06:50:40Z")

</div>

Patrick,

There is a method on foundset: isInFind().  
Btw, when a foundset is in find mode, calling find() on it will do nothing and return true.

Rob

---

<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:** [September 19, 2011, 7:10am UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/3 "2011-09-19T07:10:04Z")

</div>

Rob,

I was aware of that, but I don’t think it does what I need.

I have a relation e.g. customer\_to\_orders. I allow the user to perform a find in that (e.g. filter by product). In my UI I remember what was filtered for what customer ID using form variables.

Now I think that Servoy “caches” these foundsets. So if the user selects customer A, filters the relation, goes to customer B and back to customer A, the relation for customer A will still be filtered. But: at some point in time I guess, these foundsets are no longer cached but reloaded. Then my filter is gone, but my UI still thinks it’s filtered.

So my question is: can I find out not if a foundset IS in find, but has been filtered or not. I want to know if the related foundset is the “original” related foundset or further filtered by a find()/search().

You understand what I mean?

Something like: foundset.isFiltered(). This could also be useful for a non-related foundset. A way to find out if a find() has been performed or not.

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [September 21, 2011, 9:06am UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/4 "2011-09-21T09:06:02Z")

</div>

Patrick,

You are right, Servoy keeps a soft cache of related foundset that are reused every time you request a related foundset for the same base record.  
If you do a find/search on a related foundset it will change the state of that foundset and anywhere else you show/request that foundset later you may get the filtered one or a fresh one depending on whether the foundset was garbage collected.

To prevent this scenario, do not search in related foundsets, only on copies (customer\_to\_orders.duplicateFoundSet())

Rob

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [September 21, 2011, 10:32am UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/5 "2011-09-21T10:32:33Z")

</div>

Hi, we are so unhappy with this default servoy behaviour…  
It leads to very hard to find bugs…

How can we get all developers in our team to never use find/search in related foundsets or to always use foundset.loadAllRecords() when using a related foundset ![:cry:]( "Crying or Very sad")

Regards,

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [September 21, 2011, 12:13pm UTC](https://forum.servoy.com/t/how-to-figure-out-if-a-related-foundset-was-in-find/14677/6 "2011-09-21T12:13:47Z")

</div>

> patrick:  
> Something like: foundset.isFiltered(). This could also be useful for a non-related foundset. A way to find out if a find() has been performed or not.

How about using **databaseManager.getSQLParameters(foundset, boolean includeFilters)**?

If you get parameters in return, then it is a related foundset.  
Otherwise it isn’t.

This will not help you in all cases, but perhaps in some of them it will.
