We have a custom module and need to define a filter which select records based on an attribute of the logged in user. In this instance, there is a field on the user's record called "primary_territory_id."
The filter contains a section like this:
array('bsgfs_salesorg_id_c' => $current_user->primary_territory_id)
Essentially, we want all records where the field 'bsgfs_salesorg_id_c' on the module is equal to the current user's 'primary_territory_id'.
When we install this filter and run a QRR, the filter works fine for the first user to use it. But after that, the filter seems to be cached somehow and filters on the value of the first user to use it. For example, if the first user has the primary territory id of 123, the filter permanently filters to records which match 123. Even if the next user to log in has a territory id of 234, the filter is still "stuck" on 123.
The filter will reset after a QRR but is never dynamic; it just caches the value of the first user to try it.
Is there any way to get the result we want, where a filter always works based on an attribute of the user accessing the filter?
We are on 8.0.2 Enterprise. Thanks for any advice.