addFoundSetFilterParam issues

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

addFoundSetFilterParam issues

Postby Morley » Sat Oct 16, 2004 12:03 am

My solution will be hosting several clients. As users log in, I'm populating a global with their client number. From this point forward, no matter what they do, they should see only their own records. It's been my understanding by running "addFoundSetFilterParam" the first time a table is loaded (using the "onLoad" function) my purpose would be accomplished.

Here's the code:

Code: Select all
var success = controller.addFoundSetFilterParam('local_client_id', '=', 'globals.current_user_client_id');
controller.loadAllRecords();//to make param(s) effective


I have a "Show All" button that includes "controller.loadAllRecords()" among its instructions. Counter intuitively it loads zero records. And as long as I remain in that table (any form) I cannot re-establish any records, any forms. However, I can go to a different table and then return. Now the appropriate records are loaded, no problem.

I sense I'm misunderstanding something fundamental.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bcusick » Wed Oct 20, 2004 7:58 pm

Hi Morley,

Check on your form that on the "onShowAllRecords" property shows "DEFAULT" rather than something else.

Also, it's a good idea to set the addFoundSetFilterParam command as part of a startup script (I put mine in as part of the login process).

Hope this helps,

Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby Morley » Wed Oct 20, 2004 8:52 pm

bcusick wrote:Check on your form that on the "onShowAllRecords" property shows "DEFAULT" rather than something else.

Also, it's a good idea to set the addFoundSetFilterParam command as part of a startup script (I put mine in as part of the login process).


onShowAllRecords is set to Default on all forms, mostly because I've yet to explore its functionality. Hadn't really noticed it until now.

It's been my understanding addFoundSetFilterParam needs to be called by the onLoad property the first time the table is called. Not sure where I came to that understanding. That concept isn't in the docs under addFoundSetFilterParam.

If this is so, then I need a script for each table attached to one of the forms of that table. Then in the startup call each of these forms in turn. Am I on the right trail?
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bcusick » Wed Oct 20, 2004 9:26 pm

Right trail - wrong execution.

You NEVER need to create form-based methods to do that. Just create a global method - and refer to the form:

Code: Select all
forms.customers.controller.addFoundSetFilterParam('xxx','=','value')
forms.invoices.controller.addFoundSetFilterParam('yyyy','=','value2')
forms.order_items.controller.addFoundSetFilterParam('zzz','=','value3')


Just make your global method - then locate the form(s) and double click the addFoundSetFilterParam from the CONTROLLER object of the form.

Bob
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby Morley » Thu Oct 21, 2004 1:39 am

Thanks again. What about the call to controller.loadAllRecords() mentioned in the docs?
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bcusick » Thu Oct 21, 2004 8:26 am

Yes, do that after each controller.addFoundSetFilterParam() call.

Bob
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby olivier melet » Thu Oct 21, 2004 10:57 am

It's been my understanding addFoundSetFilterParam needs to be called by the onLoad property the first time the table is called.


Hi everybody,
This just to point out that on my experience, addFoundSetFilterParam is not acting on a table, but on the form foundset.
Thus, if you have several forms pointing on the same table, but having separate foundsets, you will have to call addFoundSetFilterParam for each separate foundset, not necessary with the same filter, which is actually a great feature.
Olivier Melet
Administration et projets
InfoForm SA
olivier melet
 
Posts: 183
Joined: Mon Apr 19, 2004 3:33 pm
Location: Switzerland

Postby Morley » Fri Oct 22, 2004 2:59 pm

This just to point out that on my experience, addFoundSetFilterParam is not acting on a table, but on the form foundset.
Thus, if you have several forms pointing on the same table, but having separate foundsets, you will have to call addFoundSetFilterParam for each separate foundset, not necessary with the same filter, which is actually a great feature.

Would appreciate having Olivier's observation confirmed and clarified. I've been under the distinct understanding that once the filter is evoked, it applies in all circumstances until Servoy is rebooted and the function is called again.

If Olivier is correct, that addFoundSetFilterParam only applies to the current foundset, then the function would have to be called every time a new foundset is established. If true, then significantly different coding strategies for what I'm attempting are required.

Feeling rather wobbly in my understanding here.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bcusick » Fri Oct 22, 2004 4:22 pm

Morley,

NO NEED TO PANIC! :D

He is talking about FORMS. The addFoundSetFilterParam works on individual CONTROLLERS (not TABLES). So, if you have:

Form 1 - based on customers table

Form2 - based on customers table (but have "useSeparateFoundSet" property checked

Then - you would have to set the addFoundSetFilterParam on BOTH forms since they use separate found sets.

Bob
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA

Postby Morley » Fri Oct 22, 2004 5:24 pm

Not panicing (or at least I hope I'm not) but I'm coming to the conclusion that something I thought was simple, straightforward and clearly understood now isn't. So before I write code based on erroneous assumptions I want to get really clear.

Your comment about the useSeparateFoundSet property leads me doubt my understanding of foundsets.

Coming from an exclusively FMP background, I'm used to the current set of records varying constantly through the use of the Go to Related Record (GTRR) and Find commands, then returning to all records.

Until this exchange I've been assuming SQL's foundset amounts to same thing -- the currently loaded set of records, i.e. is constantly in flux. Now I'm not so sure.

Here's my current confusion. When I do a Find using a method based on a particular form, it loads the results into that form. If I jump to another form based on the same table I DON'T see the same set of records (as FMP does when switching layouts) but rather the set of records that were current to that form the last time it displayed. Each form has its own independent foundset.

In other words, it would appear the useSeparateFoundSet function is turned on for all forms by default -- the opposite of the docs for this function.

In other words, I'm misunderstanding something fundamental. Hope I'm explaining my muddle clearly enough.
Morley Chalmers
7Office Inc.
User avatar
Morley
 
Posts: 891
Joined: Fri Apr 25, 2003 4:54 pm
Location: Toronto, Canada

Postby bcusick » Fri Oct 22, 2004 5:31 pm

Morley,

You are correct in your assumptions (basically). A "foundset" is constantly in "flux". The addFoundSetFilterParam will ALWAYS "filter" the FOUND SET on a form.

When you have more than one form based on the same table (2 forms based on the customers table) - a find in EITHER of the forms will still be filtered. This is because the foundsets are "in synch". This is the same behaviour as in FMP 7.

Now, you have the OPTION of checking a chedkbox that says "useSeparateFoundSet". Again, this is similar to FMP 7.

The "useSeparateFoundSet" appears on each FORM. If you DO CHECK IT - then you will need to apply the addFoundSetFilterParam to that foundset AS WELL - since it will be "disconnected" and treated as a separate found set.

Hope this helps,

Bob
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 30 guests

cron