Lists, Lead Scoring & Workflows

LGuillet
Member

line_item is not displayed

Hi, i need help here, i created a workflow to add a new line_item when a ceratin propertie is known and equal to a specific value. The line is create but not display in the deal used. I show you my code, workflow and some screen to describe my probleme. Thanks for help ! 

 

Capture d’écran 2023-03-17 à 13.52.08.png

Capture d’écran 2023-03-21 à 10.00.48.png

Capture d’écran 2023-03-20 à 14.41.02.png

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

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

  const dealId = event.object.objectId;

  console.log(`Deal ID: ${dealId}`);
  console.log(`Making API call to retrieve deal with ID ${dealId}...`);

  try {
    const dealResults = await hubspotClient.crm.deals.basicApi.getById(dealId, ['shipping_fee']);
    console.log('Deal results:', dealResults);

    let shipping_fee = dealResults.properties.shipping_fee;

    console.log(`Shipping fee found: ${shipping_fee}`);

    if (shipping_fee === '30') {
      console.log('Making API call to retrieve product...');
      const productId = 1176067770; // ID du produit existant à lier au deal
      const productResults = await hubspotClient.crm.products.basicApi.getById(productId);
      console.log('Product results:', productResults);

      console.log('Creating line item for shipping fee...');

      const properties = {
        quantity: "1",
        price: "30",
        hs_product_id: productId,
        name: "Frais de port"
      };
      
      const SimplePublicObjectInputForCreate = { properties, associations: [{"to":{"id":`${dealId}`},"types":[{"associationCategory":"HUBSPOT_DEFINED","associationTypeId":20}]}] };

      const apiResponse = await hubspotClient.crm.lineItems.basicApi.create(SimplePublicObjectInputForCreate);
      console.log(JSON.stringify(apiResponse));
    }
  } catch (error) {
    console.error(`Error retrieving deal: ${error.message}`);
  }
};

 

0 Upvotes
3 Replies 3
PamCotton
Community Manager
Community Manager

line_item is not displayed

Hello @LGuillet, thank you for posting in our Community!

I want to invite our top experts, @Jnix284 @franksteiner79 any recommendations to @LGuillet 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 !




Jnix284
Most Valuable Member | Diamond Partner
Most Valuable Member | Diamond Partner

line_item is not displayed

@PamCotton Wish I could help on this one, but custom coded workflows are a bit outside of my expertise, maybe @Teun could help @LGuillet or knows someone else who could?


If my reply answered your question please mark it as a solution to make it easier for others to find.



Jennifer Nixon - Delivery Lead at Aptitude 8

connect with Jen on Linkedin

franksteiner79
Key Advisor

line_item is not displayed

I'm +1 on @Jnix284 ...

Wouldn't know where to begin with custom coded workflows...

 

Sorry

Found my comment helpful? Great! Please mark it as a solution to help other community users.


Frank Steiner

Marketeer | HubSpot Expert | CRM Consultant

InboundPro

Let's Talk About Your Project