Hi @Pietro-Poli-
The issue you’re encountering with adding signer.company directly into the format_name function is likely because company is not a default property directly available within the signer object in the quote signature module. The signers object primarily contains basic contact information like first name and last name.
To include the company name, which is typically associated with the contact record in HubSpot, you’ll need to access the associated company information for each signer. This usually involves using HubSpot’s crm_associations function within your HubL code to retrieve the company linked to the contact who is designated as the signer.
Here’s a breakdown of why your approach didn’t work and how to correctly implement it:
Why format_name(signer.company, signer.first_name, signer.last_name, use_honorific) Fails:
The format_name function is designed to format a name using provided first name, last name, and optionally an honorific. It does not have a parameter or built-in capability to handle a company name in that position.
How to Correctly Include the Company Name:
You need to retrieve the company associated with the signer contact object separately and then construct the full name string yourself, incorporating the company name where you want it to appear.
Here’s a conceptual example of how you might modify your macro, keeping in mind that the exact implementation might vary slightly based on the specific structure of the signer object and available HubL functions in your quote module environment:
{# Localize the ordering of first and last name #}
{% macro localize_signer_names(signers, use_honorific) -%}
{% for signer in signers %}
{# Attempt to get the associated company for the signer's contact record #}
{% set associated_companies = crm_associations(signer.hs_object_id, "HUBSPOT_DEFINED", 1, "limit=1", "name") %} {# Assuming hs_object_id is the contact ID #}
{% set signer_full_name = format_name(signer.first_name, signer.last_name, use_honorific) %}
{% if associated_companies.results %}
{% set company_name = associated_companies.results[0].name %}
{# Construct the full name including the company name #}
{% set signer_full_name_with_company = signer_full_name ~ ", " ~ company_name %} {# Example: "John Doe, HubSpot" #}
{% do signer.update({ "full_name": signer_full_name_with_company }) %}
{% else %}
{% do signer.update({ "full_name": signer_full_name }) %}
{% endif %}
{% endfor %}
{%- endmacro %}
Where to Set Up the Company Field:
The company information itself is stored on the Company record in HubSpot and linked to the Contact record. When you associate a contact with a deal and then create a quote from that deal, HubSpot pulls information related to the contact and associated company.
You don’t need to “set up” the company field specifically within the quote module code. Instead, ensure that:
- The contacts who will be signing the quote have an associated company in your HubSpot CRM.
- The quote is associated with the correct deal and contacts.
By using crm_associations in your quote template code, you are accessing the existing company data linked to the signer’s contact record.