Help with Automation Using API

HI there,

I have no idea if I’m posting in the correct board, so apologies in advance.

I have what seem like a simple problem which I’m trying to solve via Java Script custom code in a workflow but am struggling big time (not a coder).

The context is our business sells project services, when a project is won Hubspot generates a Project Extension and a Project Hosting Conversion. these 2 new deals share a property “Parent Record ID” so we can relate them back to the original deal.

When a project extension closes, the “contract end date” will be some point in the future (usually 3 months). When this happens it means we cannot close the Project Hosting Conversion until this new contract end date.

i would like the “close date” of the Project Hosting Conversion to be updated toequal the new Project Extension “Contract End Date”.

I have played around with code and beleive i need to use the Hubspot API to search the database for deals with the same “Parent Record ID” with an additional filter on Deal Type = Project Hosting Conversion, then update the Hosting Conversion “Close date” to = Project Extension “Contract End Date”.

The logic is fairly simple but i’m not a coder so have very little idea how to do this.

Can anyone assist in what the code may look like?

Hey, @WWalsh4 :waving_hand: Thanks for your question. It’s likely the community cannot provide you with custom code. Sharing what you’ve already come up with is a better option for getting feedback.

If it were me, before we start coding, I’d do the following:

  • Determine the specific endpoint(s) you will need. In this case, it sounds like you are working with the Deals object
  • Look at rate limits. Meaning, how often are you expecting to make this call? Have you looked into how you can batch these calls if possible?
  • Use a tool like Postman to test your request in a simple manner and verify you get back only the expected Deals

One place to start is the Search API. These endpoints allow you to use filters in your requests.

Additionally, depending on how you are building, you can investigate the Add HubSpot properties to your custom code feature to see if there are any options for your use case.

Lastly, you can look at the necessary JavaScript to make the request and return on the relevant value. Then you can utilize an option like [Copy a property value](http://To%20define data outputs that can be used as inputs later in the workflow, for example with a Copy property value action:) to update the specified property.

Have fun building! — Jaycee

Hi Jaycee, many thanks for the reply that’s very useful in giving me a direction to explore!