CMS Development

nickgi
Contributor | Diamond Partner
Contributor | Diamond Partner

Showing datetime field from custom object in email

SOLVE

We have a custom object called Course which has a datetime field called start_date. How can we convert this into a pre-dertermined timezone, then output it into our email template?

 

The email is an autmated one which is sent via a Course workflow. I tried creating a custom module where it formats the date, the issue is that I'm not sure how to fetch the date from the custom object. Is there any way to access the custom object from inside the custom module? 

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Showing datetime field from custom object in email

SOLVE

@nickgi I've not actually done that before, but there's a feature in beta called Programmable Emails that allows personalization with custom objects in modules. You would first need to enable that feature on the module following the instructions here - https://knowledge.hubspot.com/email/create-programmable-emails

 

Then I don't know if this is the exact code you would use for your specific case but here's documentation to give you an idea of how to pull personalized custom object data in programmable email modules. - https://developers.hubspot.com/docs/cms/guides/email/hubdb-crm-objects#hs_cos_wrapper_widget_1632846...

Hope this helps!

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

4 Replies 4
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Showing datetime field from custom object in email

SOLVE

@nickgi I've not actually done that before, but there's a feature in beta called Programmable Emails that allows personalization with custom objects in modules. You would first need to enable that feature on the module following the instructions here - https://knowledge.hubspot.com/email/create-programmable-emails

 

Then I don't know if this is the exact code you would use for your specific case but here's documentation to give you an idea of how to pull personalized custom object data in programmable email modules. - https://developers.hubspot.com/docs/cms/guides/email/hubdb-crm-objects#hs_cos_wrapper_widget_1632846...

Hope this helps!

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
alyssamwilie
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Showing datetime field from custom object in email

SOLVE

@nickgi You can use the crm_objects function to grab information from a custom object.

{% set items = crm_objects("yourcustomobjectname") %}

{% for item in items.results %}
  {{ item.property_name|datetimeformat('%B %d, %Y) }}
{% endfor %}

 


Here's the developer doc on this if you want to read more about it: https://developers.hubspot.com/docs/cms/data/crm-objects

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
nickgi
Contributor | Diamond Partner
Contributor | Diamond Partner

Showing datetime field from custom object in email

SOLVE

When your module is embedded into a automation workflow email, how would I go about getting the current custom object this is running on from within the code?

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Showing datetime field from custom object in email

SOLVE

@alyssamwilie 😀

Any chance you have some ideas for @nickgi ?

0 Upvotes