How to use "distinct " operator within crm_objects function

I have been trying to use “distinct” operator but not success.

The docs say this:

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

But using “distinct__eq” doesn’t work, some operators are outdated in these docs, so not sure if I missed simething.

Can you help me guys?

My query looks like this: crm_object(‘object’,‘distinct__eq=pleaseworkthistime’)

Hello @ACarrillo7
“distinct__eq” operator is no longer supported in the HubSpot CRM API. You can use the “distinct” operator instead. You can use it with other fields, such as name, phone number, and company.

So, you are saying I should use this:

{% set contact = crm_objects("contact", "distinct=pleaseworkthistime") %}

If so, I also tried and it didn’t work

No, you should use the below and if there is a custom property called “distinct” or has the word “distinct” in it a contact will be returned.

{% set contact = crm_objects("contact", "distinct__eq=pleaseworkthistime") %}

Can you explain more about your use case so I can help you find the best way forward?

Ok, I have a custom property with a bunch of objects, this custom object has a property “country” and I want to get all the existing different values. I read the docs HubL functions - HubSpot docs and its says that I can use “distinct” operator. Note that “distinct” is not one of the properties.

Ok, can you include a screenshot of the custom property along with some of the information that it holds. You should be able to do this by navigating into settings. I just want to ensure what “type” of property it is. What object it is linked to and what sorts of values it holds. Based on this I should have enough information to figure out a solution for you.

Hey @ACarrillo7,

Do you have a custom property called “distinct” within your CRM? I think that is the issue as the documentation below is basically saying that there are certain reserved keywords and if you are trying to query the CRM for a custom property that happens to include a reference to any of them you need to append __eq (or whatever operator you’d like).

Please note: when building a query, the values of range, distinct, ndistinct, and startswith are reserved keywords. To query a property that uses one of those names, you’ll need to use the following format: range__eq= (rather than range=).

So for instance when using the crm_object hubl function you can provide an argument to query the crm for a contact matching specificed criteria. The below would return a contact whose first name is peter and output “peter” on the page.

{% set contact = crm_object("contact", "firstname=peter") %}
{{ contact.firstname }}

In contrast, if we decided to query based on a custom property called “favouritecolor” we would do this and the output would be the first name of the contact with a matching value.

{% set contact = crm_object("contact", "favourite_color=orange") %}
{{ contact.firstname }}

Now imagine you had a custom property called “distinct”. That is a reserved keyword so we need to do the below and it will output the contacts first name. This contact has a value of “pleaseworkthistime” within the custom property called “distinct”.

{% set contact = crm_object("contact", "distinct__eq=pleaseworkthistime") %}
{{ contact.firstname }}

I hope that makes sense and is helpful! Let me know if you’ve any questions and if it’s not helpful please share a bit more about what you are trying to achieve and we can go from there :blush: