CMS Development

shivammishra
Participant

{{request_contact}} object is empty on first page load

SOLVE

I am using bunch of contact properties via request_contact object in templates and modules(eg. request_contact.contact.email)  but sometimes it gives empty results on first page load right after I am submitting a form with hubspotutk value to set the user identity in his/her browser.

 

0 Upvotes
2 Accepted solutions
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

{{request_contact}} object is empty on first page load

SOLVE

Thank you for the clarification @shivammishra  - That makes total sense now. 

I'm honestly not sure if HS pushes the data into a queue before attaching it to the user. They might be doing that to improve response times of their API calls. This does sound like a question for a bigger gun than myself. (or maybe you found a real life legit bug). Can you pass the data as URL parameters instead?

You might also have better success posting the question in 

https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations

View solution in original post

shivammishra
Solution
Participant

{{request_contact}} object is empty on first page load

SOLVE

So I tested it thouroughly and found that its because of the time hubspot APIs take to update the record as mentioned by @tjoyce  and I am not sure if support would be able to help much here for this one usecase so I have handled it by checking at my end and only letting the user move forward when API sends the updated response. That way user sees the page only when {{request_contact}} object has the updated data.

 

Appreciate the help!! Thanks, you both.

View solution in original post

8 Replies 8
shivammishra
Solution
Participant

{{request_contact}} object is empty on first page load

SOLVE

So I tested it thouroughly and found that its because of the time hubspot APIs take to update the record as mentioned by @tjoyce  and I am not sure if support would be able to help much here for this one usecase so I have handled it by checking at my end and only letting the user move forward when API sends the updated response. That way user sees the page only when {{request_contact}} object has the updated data.

 

Appreciate the help!! Thanks, you both.

shivammishra
Participant

{{request_contact}} object is empty on first page load

SOLVE

Thanks @tjoyce . Ill post this question under the recommended category.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

{{request_contact}} object is empty on first page load

SOLVE

Hey @shivammishra 

I believe you might want to submit a support request for this one.  Looks like your portal qualifies.

Here is a link

0 Upvotes
shivammishra
Participant

{{request_contact}} object is empty on first page load

SOLVE

So user first lands on a hubspot page where hubspotutk cookie gets generated then I redirect user to a separate nodeJs application [outside hubspot] where I submit the form with hubspotutk cookie value using form submission API  (https://legacydocs.hubspot.com/docs/methods/forms/submit_form )  and then I am redirecting user to another hubspot page where I am trying to show user's first name which does not happen at first load.

 

In another scenario, I update one of the contact's custom property via serveless function which is called in a hubspot page using ajax and then I redirect user to another hubspot page where I am trying to show the value of that custom property but its empy on first load.

0 Upvotes
tjoyce
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

{{request_contact}} object is empty on first page load

SOLVE

Thank you for the clarification @shivammishra  - That makes total sense now. 

I'm honestly not sure if HS pushes the data into a queue before attaching it to the user. They might be doing that to improve response times of their API calls. This does sound like a question for a bigger gun than myself. (or maybe you found a real life legit bug). Can you pass the data as URL parameters instead?

You might also have better success posting the question in 

https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations

tjoyce
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

{{request_contact}} object is empty on first page load

SOLVE

@shivammishra - I might need more information on your data flow but, I think it does make sense that it's empty if you're setting the contact properties via javascript. 

There are a couple of things to note... 

1. {{request_contact}} is server side code so, if you're setting the utk in js, you would need to do a hard refresh on the page to re-render that dict properly

2. Be mindful of where the form is rendered and submitted in the page's javascript callstack. Although the forms appear quickly (visually) - it is generally loaded at an inconsistent time during page load and sometimes the data might be available and sometimes it isn't. so, if you are trying to populate a form, make sure you're using the javascript global events form callback api 

https://legacydocs.hubspot.com/global-form-events

 

GwaltonASJ
Member

{{request_contact}} object is empty on first page load

SOLVE

This is actually happening to me on my chromebook while entering the outcome for calls. When I use my partners ASUS it loads perfectly, every time the first time. When I use my chromebook I have to reload every page to code the call properly. I can always leave notes but most of the time my fields are empty. 

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

{{request_contact}} object is empty on first page load

SOLVE

@shivammishra 

Bringing in @tjoyce  to help out with this (he is pretty good at this stuff, but don't let him know)