On my page template, I have a custom code that allows me to pre-fill the user's details in hubspot form embed in our page if they're logged in on our website.
The code below has been working for us but somehow it just stopped working and throws an error "Error:Missing required input parameters. Object id or query is mandatory for crm_object function."
The Object id is there which is "contact_vid" but still indicates it's missing.
Any suggestions will be appreciated, thanks in advance.
{% set membership_contact_string = crm_object('contact', request.contact.contact_vid, 'email, firstname, lastname') %}
{% text "membership_contact_email", value= "{{ membership_contact_string.email }}", overrideable=False, export_to_template_context=True %} {% text "membership_contact_firstname", value= "{{ membership_contact_string.firstname }}", overrideable=False, export_to_template_context=True %} {% text "membership_contact_lastname", value= "{{ membership_contact_string.lastname }}", overrideable=False, export_to_template_context=True %}
This means that your contact ID is returning null, which would only happen if the contact isn't known. This could be two reasons that I can think of:
The contact hasn't filled out a form on your site. You could check if the contact is known and have a form popup if not, which would then refresh the page.
The contact has an adblocker of some sort that is preventing the cookies from being saved, and inhibiting hubspot from reading their contact record. This one is tougher, still check to see if the contact record is coming through, if not then maybe show a cookie permission popup requesting that disable cookie blockers on your site.