CMS Development

jskowronek
Participant

Meaning of "in", "nin" query operators of crm_objects function

The full list of query operators for the crm_objects function can be found here:

 

https://developers.hubspot.com/docs/reference/cms/hubl/functions#crm_objects

 

However, there is no clear explanation of what the more advanced operators actually do (i.e. in, nin, etc.)

 

I've read (somewhere) that the "in" operator only operates on options properties, but I can't seem to locate a definitive answer.

 

My use case is this in hubl email template:

 

{% set properties_list = "stringa,stringb,stringc" %}
{% set objects = crm_objects("CUST_OBJECT", "PROPERTY__in=" + properties_list, "propertya,propertyb,propertyc") %}

 

However this results zero results. If I clear the __in suffix and use a single property value, everything works as expected.

 

I realize crm_objects query is "ANDed", so this my attempt at querying CUST_OBJECT by multiple string values.

0 Upvotes
3 Replies 3
jskowronek
Participant

Meaning of "in", "nin" query operators of crm_objects function

FWIW, unless anyone corrects this, my assumption is that the HubL crm_object(s) function queries behave as the HubDB API docs in that "in" and "nin" apply only to number, select, and multiselect (as I has stated earlier but couldn't find where I'd seen this):

 

https://developers.hubspot.com/docs/guides/api/cms/hubdb#filter-returned-rows

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Meaning of "in", "nin" query operators of crm_objects function

Hey, @jskowronek 👋 Thanks for your post. 

 

I had a few questions to help give our community members more information.

  • Are you trying to query records where a single property might match any of multiple values? (For example, finding contacts where `status` is either "lead," "customer," or "partner")
  • Or are you trying to query records that match multiple properties, each with their own value? (For example, finding contacts where `firstname` = "John" AND `email` contains "company.com")

 

For the operators:

  • `in`: Returns objects where the property value matches ANY of the given values (is IN the list)
  • `nin`: Returns objects where the property value does NOT match ANY of the given values (is NOT IN the list)

My read of the documentation:

  • `in` checks if the property value matches ANY of the given values
  • `contains` checks if a multi-select property contains ALL of the given values
     

Thanks for the additional information! — Jaycee


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
jskowronek
Participant

Meaning of "in", "nin" query operators of crm_objects function

Thank you for the quick response and for the evidence of my hypothesis. Any ideas on the second part of my question then? If I do an exact match query "property__eq=VALUE" (expected results) as opposed to "property__in=VALUE,VALUEB" (zero results). Does the in operator only apply to dropdown/picklists? Or does it apply to string properties as well?

 

UPDATE:

 

I just noticed your link is to "crm_object" and not "crm_objects". Would that matter?

0 Upvotes