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 !

87741i41985ED6B4BFA4D8.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}`);
 }
};

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

@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?

I’m +1 on @Jnix284

Wouldn’t know where to begin with custom coded workflows…

Sorry