APIs & Integrations

PEscrieut
Member

Issues quote and custom quote template

Hello, 

 

I'm using the API to build a quote. 

If i'm using one of the standard template the quote is well generated.

If I'm using a custom quote template the amount of the quote is good but all the products are not shown (either on the PDF or WebPage)

If I recalled this quote and published it again from the Hubspot Web UI, all the products are shown. 

 

Do you have the same issue? Do you have any idea about what I'm doint wrong? 

 

 

0 Upvotes
8 Replies 8
LeeBartelme
HubSpot Employee
HubSpot Employee

Issues quote and custom quote template

Would need you to share the code you used to create the quote.

PEscrieut
Member

Issues quote and custom quote template

Hello, 

 

I deep dive alone the issue. 

 

If I'm linking only ONE line_tiem to the quote, the rendering is fine ! But if I'm adding 2 or more line_items it failed.... 

 

I tried also with the nodejs "sdk"

const productObject = {
properties: {
"hs_product_id": 89293927,
"quantity": 1,
}
}
const createLineItemsResponse = await hubspotClient.crm.lineItems.basicApi.create(productObject)
await hubspotClient.crm.lineItems.associationsApi.create(
createLineItemsResponse.id,
'quote',
createQuotesResponse.id,
'line_item_to_quote'
);
productObject.properties.hs_product_id=9253938;
const createLineItemsResponse2 = await hubspotClient.crm.lineItems.basicApi.create(productObject)
await hubspotClient.crm.lineItems.associationsApi.create(
createLineItemsResponse2.id,
'quote',
createQuotesResponse.id,
'line_item_to_quote'
);
productObject.properties.hs_product_id=96805;
const createLineItemsResponse3 = await hubspotClient.crm.lineItems.basicApi.create(productObject)
await hubspotClient.crm.lineItems.associationsApi.create(
createLineItemsResponse3.id,
'quote',
createQuotesResponse.id,
'line_item_to_quote'
);
 
One line_item it is ok, 2 or more it failled. I can create multiple item without link it is fine. 
 
As "Pro" paid solution, is it possible to have an answer ?
 
Thanks 
0 Upvotes
PEscrieut
Member

Issues quote and custom quote template

I move forward, if I reuse on of the line_item modified by the web browser, I could have multipe line. 

 

To create a line_item, I'm using this JSON: 

const productObject = {
properties: {
"hs_product_id": XXXXXX,
"hs_line_item_currency_code": "EUR",
"quantity":1
}
}
 
Is it ok ? (I will compare two line items)
0 Upvotes
PEscrieut
Member

Issues quote and custom quote template

I found the issue:

I need to set hs_position_on_quote, it is not automaticaly incremented

0 Upvotes
PEscrieut
Member

Issues quote and custom quote template

In order to create the quote I'm doing: 

await createDeals()
await LinkDealsContact()
await createQuote()
await LinkQuoteQuoteTemplate();
await createTax()
for (let i in quoteData.products) {
await createProduct(quoteData.products[i], 1);
}
await LinkQuoteProduct();
await LinkDealsProduct();
await LinkQuoteContact();
await LinkQuoteTax()
await LinkQuoteDeals()
await updateQuoteState("APPROVAL_NOT_NEEDED");
await sendQuote();

 

More detail for some specific method

Create a deal with the JSON payload::

"dealname": "Quote_XXXX",
"dealstage": "presentationscheduled",
"pipeline": "default" 

POST on https://api.hubapi.com/crm/v3/objects/deals

Create a Quote with the JSON payload:

"hs_title": "Title",
"hs_currency": "EUR",
"hs_expiration_date": 'YYYY-MM-DD',
"hs_sender_email": "mail",
"hs_sender_company_name": "VVVVV",
"hs_sender_firstname":"firstname",
"hs_sender_lastname": "LastName",
"hs_sender_company_address": "CCCC",
"hs_sender_company_city": "YYYYY",
"hs_sender_company_zip": "XXXX",
"hs_sender_company_country": "France"

 

Create LinkQuoteToCustomTemplate 

PUT/https://api.hubapi.com/crm/v3/objects/quote/"+quoteId+"/associations/quote_template/"+templateId+"/q...

 

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Issues quote and custom quote template

Hi, @PEscrieut 👋 Thanks for reaching out! Hey @Jake_Lett, do you have any tips you can share with @PEscrieut? Thank you! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
PEscrieut
Member

Issues quote and custom quote template

Can you ask your team to look on my comments? Thanks 

0 Upvotes
LeeBartelme
HubSpot Employee
HubSpot Employee

Issues quote and custom quote template

I was able to create a quote with the API in Postman and then create 2 line items and associate those line items to the quote and then view the quote in HubSpot. So I think functionally the APIs are fine. I even tried adding with product ids and it worked fine as well.

My first debugging step would be to output the results of the API calls. Something like this:

 

 

 

const createLineItemsResponse2 = await hubspotClient.crm.lineItems.basicApi.create(productObject);
console.log(createLineItemsResponse2);

const associateResponse = await hubspotClient.crm.lineItems.associationsApi.create(
createLineItemsResponse2.id,
'quote',
createQuotesResponse.id,
'line_item_to_quote'
);
console.log(associateResponse );

 

 

I would want to ensure that the response to those API calls were indeed successfull and what I thought it was. If both return 2xx status codes then we'll have to dig further.

I don't use the SDK much but I thought you had to use a nested property to get the response data.

 

So instead of createLineItemsResponse2.id, don't you have to do createLineItemsResponse2.body.id or something like that? Outputting the result of those calls should surface if you are referencing the correct properties or not.

0 Upvotes