CRM

NRevane7
Member

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hello -

 

So we utilize the CRM in two functions. The first and main is for our sales team to "quote" and sell our products, which are parking spaces. The second and the less used, but will be more in the coming future is for our Real Estate arm. 

 

What I would like to achieve is to automate the Product creation based on the closed won (or Competed for our reference) stage. All data will be in that deal in order to create the new product. I know I can work off the deal stage trigger, but will i need to write custom code to create the product, with the product name, description, sku, and pricing?

 

Thank you!

1 Accepted solution
danmoyle
Solution
Most Valuable Member | Elite Partner
Most Valuable Member | Elite Partner

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hey there @NRevane7. I think you're right that you'll need to create custom coded actions in the workflow for this. I don't believe standard HubSpot set up allows you to create a Product from a workflow - as @BérangèreL shared you can associate to Products (Line Items), but the creation as you described isn't a standard function. I think this would include some serious customization, including using the HubSpot API client to interact with the Products object. So you'll probably need to understand private apps, as well. Here's an example of the code that might get you there (I found this, I did not write this code so I have not verified it): 

const hubspot = require('@hubspot/api-client');

exports.main = async (event, callback) => {
  const hubspotClient = new hubspot.Client({
    accessToken: process.env.YOUR_PRIVATE_APP_ACCESS_TOKEN
  });

  const dealProperties = event.object.properties;

  const productInput = {
    name: `${dealProperties.property_city}, ${dealProperties.property_state} - Base Price`,
    sku: `FN-${dealProperties.property_city}`,
    description: `Parking space in ${dealProperties.property_city}`,
    price: dealProperties.rent_per_spot_medium,
    recurringBillingFrequency: 'MONTHLY'
  };

  try {
    const apiResponse = await hubspotClient.crm.products.basicApi.create({ properties: productInput });
    console.log('Product created successfully:', apiResponse);
  } catch (e) {
    console.error('Error creating product:', e);
  }

  callback({
    outputFields: {
      product_created: true
    }
  });
};

Just make sure to replace YOUR_PRIVATE_APP_ACCESS_TOKEN with your actual private app access token.

 

I hope this helps get you closer to your vision - it's interesting for sure!

 

Did my answer help? Please "mark as a solution" to help others find answers. Plus I really appreciate it!


Dan Moyle

HubSpot Advisor

LearningOps | Impulse Creative

emailAddress
dan@impulsecreative.com
website
https://impulsecreative.com/

View solution in original post

4 Replies 4
danmoyle
Solution
Most Valuable Member | Elite Partner
Most Valuable Member | Elite Partner

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hey there @NRevane7. I think you're right that you'll need to create custom coded actions in the workflow for this. I don't believe standard HubSpot set up allows you to create a Product from a workflow - as @BérangèreL shared you can associate to Products (Line Items), but the creation as you described isn't a standard function. I think this would include some serious customization, including using the HubSpot API client to interact with the Products object. So you'll probably need to understand private apps, as well. Here's an example of the code that might get you there (I found this, I did not write this code so I have not verified it): 

const hubspot = require('@hubspot/api-client');

exports.main = async (event, callback) => {
  const hubspotClient = new hubspot.Client({
    accessToken: process.env.YOUR_PRIVATE_APP_ACCESS_TOKEN
  });

  const dealProperties = event.object.properties;

  const productInput = {
    name: `${dealProperties.property_city}, ${dealProperties.property_state} - Base Price`,
    sku: `FN-${dealProperties.property_city}`,
    description: `Parking space in ${dealProperties.property_city}`,
    price: dealProperties.rent_per_spot_medium,
    recurringBillingFrequency: 'MONTHLY'
  };

  try {
    const apiResponse = await hubspotClient.crm.products.basicApi.create({ properties: productInput });
    console.log('Product created successfully:', apiResponse);
  } catch (e) {
    console.error('Error creating product:', e);
  }

  callback({
    outputFields: {
      product_created: true
    }
  });
};

Just make sure to replace YOUR_PRIVATE_APP_ACCESS_TOKEN with your actual private app access token.

 

I hope this helps get you closer to your vision - it's interesting for sure!

 

Did my answer help? Please "mark as a solution" to help others find answers. Plus I really appreciate it!


Dan Moyle

HubSpot Advisor

LearningOps | Impulse Creative

emailAddress
dan@impulsecreative.com
website
https://impulsecreative.com/
BérangèreL
Community Manager
Community Manager

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hi @NRevane7, I hope that you are having a great day! 🌞

Thank you for asking the HubSpot Community!

I'd like to share these resources that might be of interest to you:

- Create records with workflows: If you are creating a deal record, you can associate the newly created deals with line items: click the Add a line item dropdown menu to associate a product when you create a deal record.

- The solution from @karstenkoehler on this post "Workflow based on product"

Also, I'd love to ask some of our Top Experts: Hi @HubSpot_Corey, @HFisher7 and @miljkovicmisa do you have other suggestions to create a product via workflow to help @NRevane7, please?

Thank you so much! ❤️

Best,
Bérangère


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres! !
NRevane7
Member

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hello!

 

Although that is a bit of the workflow, there is more to it. What i would like to do is, once a deal from another pipeline (property management) is moved to compelted, i want to have a work flow that creates the product. So, lets say Property X is moved over to completed (deal won) from an open stage. I want to have a workflow that uses that as the trigger, then takes fields from the deal properties to make the product. So it would be Product name: {{Property City}},{{Property State}} - Base Price. SKU: FN-{{Property City}}. Billing Freq: Monthly. Unit Price: {{rent_per_spot_medium}}

0 Upvotes
BérangèreL
Community Manager
Community Manager

Creating a Product based on Closed Won Deal in Workflow

SOLVE

Hi @NRevane7 and thank you for the additional information!

I'd like to invite some of our Top Experts to join in this discussion: Hi @danmoyle, @00000 and @CHawkins do you have suggestions to help @NRevane7, please?

Have a great day and thanks so much for your contributions!

Best,
Bérangère


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres! !