How to get filters from search widget in code studio

Hi,

I’ve created a custom widget and I’m trying to get it to work with a search widget.

On the page builder I have a search widget next to my custom widget in a search type widget group.

I’ve found the widget.get_filters() function in the documentation, and have added it into main.js, but it always returns an empty array.

Is there something I’m missing to get this working?

Thanks,
Ewan

Hi Ewan,

I’ve gone ahead and attempted to replicate what you are trying to achieve and with success.

This is how I managed to successfully pass “Search Widget” field values into the custom widget.

Build Studio - Page Editor


Make sure the object for the Search Widget and the Custom Widget are the same.
Group them together using the Widget Grouping, I used a simple name like “G1”

Code Studio - main.js

Code Studio - main.htm

Interface - Page

Try and replicate this simple setup and test it works and then adapt to your use-case.

Remember to add the “Submit” button as the search field values only pass once submitted.

If you are still having problems, get in touch.

Regards
Liam Norris
Netcall Community

Hi Liam,

This is what I had done originally, but I was using a generic date filter element in the search widget which wasn’t being picked up in code studio.

Changing it to a property works but I could do with being able to use a generic date filter. Do you know if this is currently possible?

Thanks,
Ewan

Hi Ewan

Apologies for the late reply, I didn’t seem to of received a notification of your reply.

After doing some initial tests, I can confirm this does not work with the “Generic Date Filter” elements.

Let me speak to someone from core and get back to you.

Regards
Liam

Hi Liam,

Is it possible to use that array to perform a new search or a scheduled new search ?

Kind regards,
Mark