Aug 23, 202410:14 AM - edited Aug 23, 202410:26 AM
Contributor
How can all dropdown options from a product's property be passed in a filtering list?
SOLVE
I am using hubspot's product object to record different real estate projects and properties. A custom property was created for the product object, with internal value asset_type, and field type Dropdown select. Same for bedrooms, and bathrooms.
A module has been created to display, with the ability of filtering, properties listings - a card-type list of properties, dependent on filters, containing information about those properties. For the time being, I am trying to make just a few filters work, before moving on to add filters.
I managed to make the minimum and maximum price work as filters, i.e.: when they are set, both of them together or independently of one another, and the filter button is hit, what is then displayed are only the correct properties.
However, I am stuck with the other ones. What is displayed as an option in all the lists is simply 'All', but for each of those lists what I want displayed are the existing dropdown options found in the product object's properties. I do not want to hard-code the drop-down options (apartment, house, studio, etc; 1, 2, 3, etc). That is suboptimal, as those options may change at any time, which means they got to be hard-coded again; plus, more filters will be added for this module and others later on, and each time those options could change also. I want to pull the dropdown options directly from the property itself, as set within properties settings of the product object.
This will return a dynamic list of all available options in the properties you designate when declaring it and will update as the dropdown options change.
How can all dropdown options from a product's property be passed in a filtering list?
SOLVE
@DrAS - From a property related API call, you can retrieve all possible options for a dropdown list (as you have found) as an array. Applying this array (or subsets of the array) to a search API filter can be done with an IN filter type and values array.
Note these API calls can't be made from client side JS (only HubDB APIs are permitted in this context) - so it seems likely that the HubL option offered in this thread is going to be the best option for the display you want.
This will return a dynamic list of all available options in the properties you designate when declaring it and will update as the dropdown options change.