APIs & Integrations

jasonashaw
Contributor

How to pull the max vidid, or max value of custom field?

I am working on an integration and would like to be able to pull the max customerID (my own property) of contacts in our hubspot clients so we know where to start the import of new records.

 

We pulled the recent_contacts, but having tremedous difficulty extracting the customerID values. I am hoping for suggestions on how to unpack the result set to find the max customerID among the X recently added contacts, or if there is an even simpler way to do this.

 

I'll need to do the same thing with deals (finding max of our OrderID)

 

Please let me know.

 

Thanks!

Jason

 

0 Upvotes
3 Replies 3
Mike_Eastwood
Key Advisor | Gold Partner
Key Advisor | Gold Partner

How to pull the max vidid, or max value of custom field?

Hi @jasonashaw 

 

You could add new Contacts to a Static List (with a workflow or an API call) then remove them from the Static List with the API. 

 

This means you're only downloading a small batch of Contacts at a time (making it easier to walk the list).

 

Alternatively, you could have a Custom Property called "Processed" checkbox (set by the API). Then you can download all the Contacts from the Active List (where "Processed" is false). Do your processing, then set"Processed" to true (so they disappear off the list).

 

Does this help?

Have fun

Mike

 

jasonashaw
Contributor

How to pull the max vidid, or max value of custom field?

Thanks Mike! I very much appreciate the ideas  and awesome worarounds.

 

The issue is that I need to know on the MySQL side which records need to go into Hubspot. Knowing the max(customerID) in Hubspot would make it very easy to know, btu I am having the hardest time figuring this out. I can get the data from Hubspot, and the key/value we need is in there - but extracting the specific value from the morass of dictionaries and lists is beyond my current capabilities.

 

Taking your line of thinking it might be much easier to just create a table in MySQL that tracks the max(customerID) exported to Hubspot. I don't like this as much because I'd rather works from the max in Hubspot because that tells me what is actually there.

 

Thanks!

Jason

0 Upvotes
Mike_Eastwood
Key Advisor | Gold Partner
Key Advisor | Gold Partner

How to pull the max vidid, or max value of custom field?

Hey @jasonashaw 

 

Difficult to know exactly what yo need without discussing your goal.

 

However, I would keep track of everything outside HubSpot (in MySQL).

 

When you "Create of Update" your Contact in HubSpot the Contact's VID is returned – I would save the VID as a key in MySQL (for future use). And, when you Create or Update there's a flag returned "isNew".

 

Personally I think it's risky using the Max Customer ID as a way to decide if your Contact is new.

 

Have fun

Mike