Skip to main content
Best answer

How to find the most recent HubSpot deal in a loop

  • July 16, 2025
  • 3 replies
  • 8 views

earlywork_team
Forum|alt.badge.img+1

Hey team đź‘‹

I’m trying to build a Zap that does the following 

  1. When given a company domain → find the company ID in Hubspot 
  2. From the company ID, find the associated deals 
  3. If there is 1 deal, get deal details and update Google Sheet
  4. If there are multiple deals, find the deal with the most recent activity, then get details of that deal

I’m struggling with step 4 here - trying to sift through multiple deals. I imagine there’s probably a loop somewhere involved. 2 questions from me so far

  1. Step 4 is the “Find Associations” step from Hubspot and I’ve been able to find the Hubspot IDs successfully. However, when I put it through the loop, it sees the result as one long string instead of individual IDs. I've tried converting it to text instead of line items but then the “Get Deal” step from Hubspot fails as it seems to be expecting a number
  2. What would the logic of the loop be to sift through multiple deals and find the one with the most recent activity date. Would be great to get some help on the specific steps needed to do this since we need to dynamically compare values 

 

Thanks in advance!

Best answer by Troy Tessalone

Hi ​@earlywork_team 

Options to try:

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

Troy Tessalone
Zapier Orchestrator & Solution Partner
Forum|alt.badge.img+14
  • Zapier Orchestrator & Solution Partner
  • 34001 replies
  • Answer
  • July 16, 2025

Hi ​@earlywork_team 

Options to try:


earlywork_team
Forum|alt.badge.img+1
  • Author
  • Beginner
  • 12 replies
  • July 16, 2025

Hey ​@Troy Tessalone !

Thanks for the nudge to use the Custom Action - haven’t ever used this before but I think i’ve got it working!

Cheers,

Marina


JammerS
Forum|alt.badge.img+6
  • Zapier Staff
  • 3527 replies
  • July 17, 2025

Wow! Thank you for confirming that Troy’s resolution got the Zap running. This will significantly help our Community members to have as a reference for the same issue.