🏆HubSpot Themes Challenge 2021 - 2nd Prize Winner! View Theme
Contact

    Find the deals associated with a contact on a HubSpot membership page

    Difficulty Level: Advanced. This post assumes a strong understanding of HubSpot tools and technical knowledge. Insutructions are given as guidelines and may require additional customisation.

    In HubSpot, you can create pages where users can view their own information when logged in. For example, the deals associated with their contact record.

    Get a contact's data

    To get a contact's data on your HubSpot CMS page, you can use the crm_object or crm_objects HubL functions. For security reasons, this can only be done on a password-protected or membership login page. 

    To get a contact's first and last name using the crm_object function, you would write something like the following code, with the three parameters being the object type ('contact'), the object ID (in this case retrieved from a logged-in member - request.contact.contact_vid), and the object fields you'd like to retrieve ('firstname,lastname'): 

    See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 1 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.

     

    Get a contact's associated deals

    To get this contact's associated deals, you would use the crm_associations HubL functions and write something like the following code, with the three parameters being the object ID (again, in this case, retrieved from a logged-in member- request.contact.contact_vid), the object category ('HUBSPOT_DEFINED'), the association type ID (in this case 4, "Contact to deal") and the object fields you'd like to retrieve ('dealname,amount'): 

    See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 2 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.

     

    The above two code snippets should render the following HTML when a user is logged in: 

    See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 3 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.

     

    You can retrieve any data from other object types (product, marketing_event, contact, company, deal, ticket, quote or custom if you have an Enterprise account) and their associations by using variations on the code above with the relevant parameters.

    Written by: Stephanie O'Gay Garcia Last Updated: March 6, 2022

    Thank you! I appreciate the feedback 😊

    Sorry to hear that! 🙁

    I'd appreciate if you could take a moment to let me know how I can improve this article.

    hand-drawn-monitor-and-mouse

    Looking for a HubSpot website developer?

    Let me help you with website themes, templates, page setup and custom modules. 

    Get in touch

    Stephanie O'Gay Garcia

    Hi! 👋 I'm a freelance HubSpot Website Developer based in Toronto (Canada). Give me a shout if you have questions about this post or there's anything I can help you with.