⚙ Operations Hub

SupportW
Member

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

The environment I'm working in is integrated with NetSuite using HubSpot's app. Invoices are created in NetSuite and sync back to HubSpot.

 

The current process only brings a Company association to the Invoice as the invoices aren't usually tied to opportunties within NetSuite (just Customer).

 

We have a custom property that syncs over which currently contains the HubSpot Deal's name.

 

Is it possible to write a custom code that would take the deal name from this custom property then associate it to the Deal record with the exact name match?

0 Upvotes
1 Accepted solution
aviafriat26
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

@SupportWI've had a similar setup with HubSpot and NetSuite. You can definitely write some custom code to link those invoices to deals based on the deal name. Try this:

 

  1. Grab the Deal Name: Pull the deal name from the custom property on the invoice.
  2. Find the Deal: Search HubSpot for a deal that matches that name.
  3. Link Them Up: If you find a matching deal, associate the invoice with it.

Here's a quick idea of what the code might look like:

// Pseudo-code for custom workflow
// Get the deal name from the invoice's custom property
let dealName = invoice.customProperty; // Replace with how you actually get the custom property

// Search HubSpot for a deal with that name
let matchingDeal = hubspot.deals.search({ name: dealName }); // Replace with the real API call

// If you find a matching deal, associate the invoice with the deal
if (matchingDeal) {
  hubspot.invoices.associate(invoice.id, matchingDeal.id); // Replace with the real API call for association
} else {
  console.log('No matching deal found for invoice');
}

 

You'll need to tweak the API calls to fit your setup, but this should get you moving in the right direction.

Hope this helps!

 

If anyone else has tips or tricks, jump in!

Avi Afriat

View solution in original post

5 Replies 5
aviafriat26
Solution
Participant | Diamond Partner
Participant | Diamond Partner

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

@SupportWI've had a similar setup with HubSpot and NetSuite. You can definitely write some custom code to link those invoices to deals based on the deal name. Try this:

 

  1. Grab the Deal Name: Pull the deal name from the custom property on the invoice.
  2. Find the Deal: Search HubSpot for a deal that matches that name.
  3. Link Them Up: If you find a matching deal, associate the invoice with it.

Here's a quick idea of what the code might look like:

// Pseudo-code for custom workflow
// Get the deal name from the invoice's custom property
let dealName = invoice.customProperty; // Replace with how you actually get the custom property

// Search HubSpot for a deal with that name
let matchingDeal = hubspot.deals.search({ name: dealName }); // Replace with the real API call

// If you find a matching deal, associate the invoice with the deal
if (matchingDeal) {
  hubspot.invoices.associate(invoice.id, matchingDeal.id); // Replace with the real API call for association
} else {
  console.log('No matching deal found for invoice');
}

 

You'll need to tweak the API calls to fit your setup, but this should get you moving in the right direction.

Hope this helps!

 

If anyone else has tips or tricks, jump in!

Avi Afriat
SupportW
Member

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

This is very helpful. Thank you!

0 Upvotes
PamCotton
Community Manager
Community Manager

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

Hey @SupportW, thank you for posting in our Community!

 

Yes, it is possible to write custom code that takes the Deal name from the custom property and associates the Invoice to the Deal record with the exact name match.  To our top experts, @james-portant, and @aviafriat26 do you have any recommendations for @SupportW matter?

 

Thank you,

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !




0 Upvotes
SupportW
Member

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

Thank you for looping in these talents. I really appreciate everyone's support.

0 Upvotes
james-portant
Contributor

Workflow Custom Code to Associate an Invoice Record to a Deal Record

SOLVE

Thanks for the shout out @PamCotton. It looks like @aviafriat26 has got it sorted! 💪