How associate a custom object in a customized quote template

Hi everyone,

I’m working on a customized quote template in HubSpot, and I need to display data from a custom object called Pets, which is associated with a deal.

The idea is to generate a pricing table within the quote that shows each associated line item along with the corresponding Pet. So the desired output would look something like:

Pet Name | Plan Name | Price
Nina | Plan A | R$100
Sonic | Plan B | R$80

The “Pets” custom object is already set up in the portal with properties such as “matricula”, “nome_do_pet”, and “sexo_do_pet”. It is also correctly associated with deals using a label called “Pet”.

Line items render correctly using the variable “QUOTE.associated_objects.line_items”, and I am successfully looping through them.

To retrieve the Pets, I initially tried using:

{% set PETS = DEAL.associated_objects.Pet %}

However, this returned nothing. I then added a debug line to print out the full object structure:

{{ DEAL.associated_objects|tojson }}

And I noticed that the custom object data is actually being returned inside a key like:

DEAL.associated_objects.custom_objects._2_47534741

That array contains the Pets data like this:

[
{ “matricula”: “Nina”, “nome_do_pet”: “Nina” },
{ “matricula”: “Sonic”, “nome_do_pet”: “Sonic” }
]

So I tried:

{% set PETS = DEAL.associated_objects.custom_objects._2_47534741 %}

And then inside the loop:

{% set pet = PETS[loop.index0] %}
{{ pet.nome_do_pet }}

Even though the data is clearly there (confirmed by tojson), nothing is rendered when I try to print the Pet name. No error, just no output. remains blank.

Are custom object associations supported in quote templates using the custom_objects._ID format?
Is there a more stable or recommended way to pull data from custom objects within quote templates?

``

Hello, I would attempt using matching keys instead:

If you’re doing:

{% set pet = PETS[loop.index0] %}

That assumes your line_items array and your pets array are in perfect 1-to-1 order — and that’s not guaranteed unless you enforce that relationship somewhere else in your data model.

Instead I would attempt using a matching key instead:

Ideally, your Line Items and Pets have some shared key (like a matricula, pet_id, or even a matching order) so you can do something like:

{% for item in QUOTE.associated_objects.line_items %} {% set pet = PETS | selectattr(“matricula”, “equalto”, item.product_id) | first %} <tr> <td>{{ pet.nome_do_pet }}</td> <td>{{ item.name }}</td> <td>{{ item.price|format_currency }}</td> </tr> {% endfor %}

Make sure item.product_id or a similar field on the line item maps correctly to something like pet.matricula.

Let me know if this helps, or if you have any other questions!


:check_mark: Was I able to help answer your question? Help the community by marking it as a solution.

Brandon Woodruff
Senior Software Developer @
Pearagon
Still have questions? Reach out at brandon@pearagon.com