Using AddFoundSetFilterParam

I’m attempting to add a filter to a form. In this case my filter is records whose “sevenid” field is equal to a global field.

//Add a filter parameter to limit the foundset permanently
var success = forms.peopleMain.controller.addFoundSetFilterParam(forms.peopleMain.record.seven_id, '=', globals.gseven_id);
forms.peopleMain.controller.loadAllRecords();//to make param(s) effective

globals.gseven_id currently has a value of 2. Records in the table have values of 1, 2 or empty in the field seven_id.

I’m getting this error:

Conversion Error: The undefined value has no properties.

This is my first pass through this function. I replaced the sample parameters with my own. The method itself is a global method. Can someone spot what I’m missing?

have you tried

var success = forms.peopleMain.controller.addFoundSetFilterParam('seven_id', '=', globals.gseven_id); 

?

patrick:
have you tried?

var success = forms.peopleMain.controller.addFoundSetFilterParam('seven_id', '=', globals.gseven_id); 

Returns

Reference Error: ‘seven_id’ is not defined.

This filtering method is a Global Method, triggered as soon as the user logs in. Therefore identifying the table the field is part of makes sense.

Still puzzled.

Still not functional but I’ve solved the undefined parameters problem.

//Add a filter parameter to limit the foundset permanently
var success = forms.peopleMain.controller.addFoundSetFilterParam(forms.peopleMain.seven_id, '=', globals.gseven_id);
forms.peopleMain.controller.loadAllRecords();//to make param(s) effective

I took out the word “record”. Was formerly```
var success = forms.peopleMain.controller.addFoundSetFilterParam(forms.peopleMain.record.seven_id, ‘=’, globals.gseven_id);


I've just started using Servoy 2.1. 

However the function still doesn't do the filtering I was expecting it to. Still puzzled.

without checking, I would say that the first parameter has to be the column name of the column you are using to filter. So if there is a column named “seven_id”, then it should work.

patrick:
without checking, I would say that the first parameter has to be the column name of the column you are using to filter. So if there is a column named “seven_id”, then it should work.

Unfortunately, it doesn’t.

Hi,

I had a similar problem using AddFoundSetFilterParam,
It was applied on a form called in a tabpanel. Results where filtered on the form itself but not in the tabpanel!!

I finally had to make a global method linked to onShow of the form showing the tabpanel.

nb : the method is similar to yours but I use loadRecords instead of loadAllRecords, I can’t explain that choice :?

you have to do this:

forms.peopleMain.controller.addFoundSetFilterParam(‘seven_id’, ‘=’, globals.gseven_id);

this should work fine.

Look at the sample code of addFoundSetFilterParam
You have to set the name of the column as a string.

If this doesn’t work please send a small sample to me.
When is this code triggered? What method? (the best thing is to do this in the onLoad method of the form it self:

controller.addFoundSetFilterParam(‘seven_id’, ‘=’, 7);

the best thing is to do this in the onLoad method of the form it self

I personnaly have to look deeper in the management/meening of onLoad and onShow, but from my short experience, using an addFoundSetFilterParam method in the onLoad of a form works perfectly only if the table you want to filter is the one the form is based on.

If the form is called somewhere else in a tabpanel the filter isn’t efficient anymore (in my case).
There are some other posts about addfilterparam but none speaks of this so I’m not completly sure.

jcompagner also pointed the fact that if onShow is used :

you add a param everytime you go to that form.

:cry:

There’s surely more to be said.

When you are displaying the form in a tabpanel then you are displaying related data in it?
In related foundsets the filter doesn’t work. This only works in ‘normal’ foundsets. You have to add the filter param youreself in the relation.

onLoad works fine!!! :o

Yes it is related data.

Infact I try to manage users.
I have a Company form that every user can browse and i have a tabpanel where Actions linked to the current company are shown.
Actions are specific to each user and so can only be seen by the one who created them (i have a userName row on Action table).

I’ve just created a global = userName wich is set when the solution is loaded.
I now use it in my Company_to_Actions relation : global.userName = action_userName.
I place addfoundsetfilterparam in the onLoad of Actions form and now it works just fine!!

I didn’t thought about using a global in a relation.
A thousand thanks. It’s really great.