APIs & Integrations

06018
Participant

String Comparison in Search API

SOLVE

Consider the following POST to /crm/v3/objects/companies/search

data = {
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "sync_id",
                    "operator": "LT",
                    "value": "1TVj11"
                }
        },
    ]
}

You would imagine that "1TVfTD" would be returned since lexographically 1TVfTD < 1TVj11. However, this has proven to not be the case. Could someone provide some insight on how strings are compared in the Hubspot API? An extension question would be if lowercase characters are considered lesser or greater than uppercase characters.

Edit: I will add, "1TVfTD" is returned when compared against "2", but not against "1Z". What gives?

0 Upvotes
1 Accepted solution
SteveHTM
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

String Comparison in Search API

SOLVE

Given this information, I think you may be better off formatting the property as a date or datetime (where the underlying property values in HS are actually millisecond UNIX epoc counters) Then you have a lot more flexibility for comparison or range selection in a search.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature

View solution in original post

0 Upvotes
3 Replies 3
SteveHTM
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

String Comparison in Search API

SOLVE

@06018 - Although you may find this unsatisfactory, I feel you may be reaching into an arena of undefined or at least underdocumented behaviour. For my part, I only use GT, LT type comparisons on numeric properties. And limit string operations to EQ, NEQ or CONTAINS_TOKEN, etc.

 

Good luck!

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes
06018
Participant

String Comparison in Search API

SOLVE

I see. The strings I am trying to compare are base62 representations of Unit time (seconds since Jan 01 1970). I suppose I could use integers for this, but this should be documented somewhere

0 Upvotes
SteveHTM
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

String Comparison in Search API

SOLVE

Given this information, I think you may be better off formatting the property as a date or datetime (where the underlying property values in HS are actually millisecond UNIX epoc counters) Then you have a lot more flexibility for comparison or range selection in a search.

 

Steve

Steve Christian

HTM Solutions

https://info.htmsolutions.biz/meetings/stevec2

mobilePhone
+1 6195183009
emailAddress
stevec@htmsolutions.biz
website
www.htmsolutions.biz
address
San Diego, CA
Create Your Own Free Signature
0 Upvotes