La fonction de suggestion automatique permet d'affiner rapidement votre recherche en suggérant des correspondances possibles au fur et à mesure de la frappe.
déc. 7, 202111:47 PM - modifié déc. 8, 202112:08 AM
Membre
How to write a crm_objects query to match a substring?
Hello,
I am writing a custom module to display specific products on a page. I want to filter all my products based on a tag, in this case the `ip__shopify__tags` property.
I am trying to write a query like this:
{% set products = crm_objects(dynamic_page_crm_object_type_fqn, "ip__shopify__tags__contains=215","ip__shopify__tags") %}
But it does not filter them, it returns all 81 of my products and I'm expecting 25.
I tried modifying the query to use "in", like this: `ip__shopify__tags__in=215`
But it returned 0 products.
I should note that when I remove the query param and simply request all my products I get 81 results. I know this string querying should work in principle, because it is working fine via the REST api using the CONTAINS_TOKEN operator:
How to write a crm_objects query to match a substring?
Hello,
I am writing a custom module to display specific products on a page. I want to filter all my products based on a tag, in this case the `ip__shopify__tags` property (I'm building a shop using the Shopify Integration).
I am trying to write a query like this:
{% set products = crm_objects(dynamic_page_crm_object_type_fqn, "ip__shopify__tags__contains=215","ip__shopify__tags") %}
But it does not filter them, it returns all 81 of my products and I'm expecting 25.
I tried modifying the query to use "in", like this: `ip__shopify__tags__in=215`
But it returned 0 products.
I should note that when I remove the query param and simply request all my products I get 81 results. I know this string querying should work in principle, because it is working fine via the REST api using the CONTAINS_TOKEN operator:
Contributeur de premier rang | Partenaire solutions Platinum
How to write a crm_objects query to match a substring?
Hello @jplew , 👋@dennisedson ! Thank you for writing in the forum, it seems that the contains query operator is only applicable for multi-valued properties, as per the documentation. Have you tried the in operator?
If my answer was helpful please mark it as a solution.
thanks for the suggestion. In my original post I mentioned that I tried "in" already and it returns 0 results. So it's either buggy or not what I'm looking for.
The documentation is not clear either on its intended usage, nor does it give any examples. For example how do I search for a string with spaces? Which one of these?
"ip__shopify__tags__in=dry trimmer"
"ip__shopify__tags__in=dry%20trimmer"
"ip__shopify__tags__in='dry trimmer'"
I can't verify these because nothing works.
Is it possible to bypass the clunky `crm_objects` method altogether and invoke the Hubspot API? I don't see why HubL coders or custom module builders should be denied the opportunity to use the API, which is far better documented than the native HubL functions.
Contributeur de premier rang | Partenaire solutions Platinum
How to write a crm_objects query to match a substring?
@jplew I also see another thing and I'm not sure if that causes the issue but the internal name of the property seems to have double underscores which is the way that hubspot differrentiates the operator from the property name, so maybe that's why it's buggy, maybe try it with another property and see if it works okay, properties should have single underscores, something like the following: ip_shopify_tags__in=dry trimmer
P.S.: The query should take care of the spaces accordingly in its internal call so I wouldn't worry about that.
How to write a crm_objects query to match a substring?
That's a clever suggestion. I don't think that's the problem however, since I've used operators on other properties with a double-underscore. When I use the "in" operator with another property I still get 0 results. My actual queries look like this: