We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Jan 20, 2022 9:46 AM
I have tested my use case of crm_associations with a test value and that is not the issue. This works as expected:
{% set associated_objects = crm_associations(12345, "USER_DEFINED", 123) %}
However passing the contact id to this method has not worked.
Here are a few things I have tried:
{% set contact_id = contact_without_defaults.hs_object_id %} - this prints as the correct contact id
{% set contact_id = contact_without_defaults.hs_object_id|int %} - this prints as 0
{% set contact_id = contact.hubspot_contact_record %} - I have tried this along with split and replace to get the end part which is the id, which doesn't work, so I would try to cast that to int but split and replace don't work, even after casting to string
{% set contact_id = contact.contact_vid %} - this seems to exist only on pages and not in email modules
Are there any other ways to obtain the contact id and pass it to a method within an email template?
Jan 20, 2022 10:43 PM - edited Jan 20, 2022 10:44 PM
Hey @JustinDowty
Have you tried "contact.id"? I've found that sometimes "hs_object_id" works and other you need to use "id". I'm sure there is a logical reason for that but I haven't found the time to test it.
Jan 26, 2022 8:48 AM
Hey @Kevin-C
Yes I have tried that as well. I have tried what feels like every way I could possibly come up with. Is this possibly a bug that needs to be reported? It seems to me like this use case would be a common one for the crm_associations function.
My use case is for an email module that will display the travel agent information assigned to each recipient of an email. This might be a make or break thing for setting up this clients email marketing system.