setFilters from IM API not working


I’m using the exposed Interaction Manager API to handle filters that I’ve stored. So I’m doing something like this:

var filters = getStoredFilters()
var api = cf.getIManager().get('api')


I get no errors, but the visualizations are not affected.


Hi, @ahmed. Is filters an array of Filter objects? A Filter object has to be created with the cf.Filter class as specified here: Filters.


Because of your answer I realized that I was using an array of objects instead of cf.Filters, as soon as I changed them it did work, so thanks! Problem solved.

As a suggestion I think it would be good to print some warning or message to let the user know about the error and what it should do, since I see that is very easy to misunderstand this method about the parameter it receives.


Although the documentation is clear about it (the example is actually using a Filter object) you are right. api.setFilters is commonly used to set initial filters to the Interaction Manager when the application loads, that’s its main use, and usually these filters are stored in a JSON format so that’s why we’ve noticed it could be a common issue to forget to convert them into cf.Filters before.

We’ll take your recommendation in consideration. Thanks!


I’m using api.setFilters for setting new filters, but at some point I need to remove all existing filters and set a new array, but I’ve noticed that is keeping the old set plus the new one I’m setting.

Is there a better way to do this or do I have to delete them using api.removeFilter?


Hi @oliver, api.setFilters takes a boolean as second parameter which by default is false, if true, the Interaction Manager will clean any existing filter and will set the new array. Now, something important that I should say is that by doing this, it will only clear the state of the Interaction Manager, it will not delete filters from the visualization! If you want to do this programmatically, you can use api.deleteAllFilters to remove them all from the IM and the visualizations which will create new queries of course.