CMS Development

ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Hello,
 
I have a complex scenario that i am trying to solve. Basically what we require is a website/landing page, that can fetch and display data based on a contact ID that is passed in the URL as a parameter maybe.
Another section of this page would be able to write data to the CRM (I was thinking of embedding a form for the same).
 
So to sum it up, i'll give a live scenario that we are expecting:
1) Share a link with a contact
2) Display the data fetched form inside this contact (and from associated objects if possible)
3) If this contact fills the input fields, update the properties related to this contact.
 
In your opinion, what is the best practice to achieve this?
 
Thanks!
@ChrisChiha 

0 Upvotes
1 Accepted solution
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Website/Landing page that fetches and write data to CRM

SOLVE

So your code should be: 

{% for deal in deals.results %}
<li>{{ deal.customer_full_name }}</li>
{% endfor %}


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


View solution in original post

10 Replies 10
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Website/Landing page that fetches and write data to CRM

SOLVE

Hi @ChrisChiha ,

 

Check out this page of the docs. You should be able to use the `crm_object` and `crm_associations` functions. For the form, I would advise you to use a default HubSpot form and add contact properties and other object properties to the form. You are not limited to only using contact properties in your form.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Hey @Teun ,
 
This is what i have in my module so far. i am able to fetch the property values for the contact passed in the dynamic page, but for the associated deals to this contact, it is diplaying nothing. I even tried to pass the contact id directly in the code to test, but still no luck:
  

{% if dynamic_page_crm_object %}

{% set user = dynamic_page_crm_object %}

<h1 style="color:#000000;">{{user.firstname}} {{user.lastname}} <br/> {{user.email}} <br/> {{user.phone}} </h1>


{% set contact_id = request_contact.contact_vid %}
{% set deals = crm_associations(contact_id,"HUBSPOT_DEFINED", 4) %}

<ul>
{% for deal in deals %}
<li>{{ deal.customer_full_name }}</li>
{% endfor %}
</ul>


{% endif %}

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Website/Landing page that fetches and write data to CRM

SOLVE

Hi @ChrisChiha ,

 

You can only access deals from a membership or password-protected page. Is this the case for the page you are building? Only products, marketing events, and custom objects are available on public pages.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Hello @Teun ,

 

Yes, the page is private (password protected).
 

0 Upvotes
Teun
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Website/Landing page that fetches and write data to CRM

SOLVE

Hi @ChrisChiha ,

 

So I checked the following things:

1. Your definition ID of the association is correct.

2. It is a HubSpot-defined association, so that is correct as well.

 

This leaves the contact ID itself. If you use {{contact_id|pprint}} does it show a correct value? And if you use {{deals|pprint}}, what does that give you?
And if you paste the contact ID directly as a string in the function, does that change anything?
{% set deals = crm_associations("1234","HUBSPOT_DEFINED", 4) %}

{{deals|pprint}}


You could also try this:

 

{% set deals = crm_associations(contact_id,"HUBSPOT_DEFINED", 4, "limit=50", "customer_full_name", false) %}

 

Because it could be that you need to retrieve the specific property.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


0 Upvotes
ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Hey @Teun , good news!
  
When i am doing the {{deals|pprint}}, it is returning the associated deals as follow:
 
(CrmObjectList: {hasMore=false, offset=2, results=[{customer_full_name=test2 test2, id=6802074961}, {id=9613818449}, {customer_full_name=test test, id=9614892653}], total=2})
  
The issue seems in the for loop

0 Upvotes
ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Screen Shot 2022-10-17 at 4.58.08 PM.png

0 Upvotes
Teun
Solution
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Website/Landing page that fetches and write data to CRM

SOLVE

So your code should be: 

{% for deal in deals.results %}
<li>{{ deal.customer_full_name }}</li>
{% endfor %}


Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


BarryGrennan
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

You can build dynamic pages based on crm objects 

 

Limitations of that approach would be that as you're using company info the page needs to be password protected.

 

If you don't want to go that route, I imagine it'd need to be the CRM API

 


profile2022aBarry Grennan

Freelance HubSpot CMS Developer

Website | Contact

 

 

0 Upvotes
ChrisChiha
Top Contributor

Website/Landing page that fetches and write data to CRM

SOLVE

Hey @BarryGrennan ,
 
Thanks for your reply!
 
I tried dynamic pages, but went through some issues configuring the page slug.
I picked contact record id as the page slug, but wasn't able to configure it / pass it to the page to display accordingly.
 
Are you aware if i can access the associated objects of the contact i am fetching to the page?

0 Upvotes