# Question about custom code module

**URL:** <https://community.hubspot.com/t/question-about-custom-code-module/79935>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [April 24, 2023, 4:29pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935 "2023-04-24T16:29:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EKight](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@EKight](https://community.hubspot.com/u/EKight)\
**Post date:** [April 24, 2023, 4:29pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/1 "2023-04-24T16:29:19Z")

</div>

My company is working with a partner that creates user-personalized features at scale. (For example, having the number of reward points that a user has earned display in an email sent to all user and each person only sees their own reward information.)

Our team wants to display a progress bar in an email. The progress bar image shows three stages. When a user receives that email, it would display the image of the progress bar that correlates with the status that they are in. This status is listed in a field within their contact in HubSpot. The partner that we’re working with has provided us with code that shows an image of that progress bar in a specific status. This shows the user what stage they are currently in.

We tried dropping the code into an HTML block in one of our templates and sending it to a HubSpot contact with one of the three status without success. The HubSpot team told us we might need to build it in the custom template section, so we created a custom module and dropped the code into that. We then added that module to an email and send that to a HubSpot contact with one of the three statuses.

That isn’t working either. In both instances, the code doesn’t seem to have errors, but the status field is blank, even though the contacts themselves have a valid status in that field in HubSpot. The partner we’re working with says that their code isn’t the problem because the code itself displays the right thing, it’s the intregration with hubspot that is causing an issue.

Here is the code:

\<a href=“[https://mi.mccarthylawyer.com/p/cp/53d56e6b6d616e2c/c?mi\_u=](https://mi.mccarthylawyer.com/p/cp/53d56e6b6d616e2c/c?mi_u=){{ contact.email }}&mi\_ign={{ sendID }}&mi\_fcraleadstatus={{ fcra\_lead\_status }}&url=https%3A%2F%[2Fmi.mccarthylawyer.com](http://2Fmi.mccarthylawyer.com)%2Fp%2Frp%2F2502da306657f8ec%2Furl” style=“display: block”\>\<img alt=“Display images to show real-time content” style=“border: 0; display: block;” border=“0” src=“[https://mi.mccarthylawyer.com/p/rp/2502da306657f8ec.png?mi\_u=](https://mi.mccarthylawyer.com/p/rp/2502da306657f8ec.png?mi_u=){{ contact.email }}&mi\_ign={{ sendID }}&mi\_fcraleadstatus={{ fcra\_lead\_status }}” /\>\</a\>

Here’s a public link: [Movable Ink Studio](https://app.movableink.com/campaign/53d56e6b6d616e2c/channel/35547/embed-codes)

Here are the images of each status the way they should display in the email:

 ![EKight_2-1682353310046.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/4/1/413498660394b11f56f25bc1c78965ff279faeaf.png)

 ![EKight_1-1682353294079.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/8/80db2e3fdaeea28cc666921319908c9ab8a1e2cd.png)

 ![EKight_0-1682353271623.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/7/37232d4269a0a3e647808fd3ffcb67086a0e068a.png)

Here is the cusom module where we are attemting to add the code in order to use it in an email (the code cuts off in the screen but we’re pasting the full code listed above into the module as seen below):

 ![EKight_0-1682353594013.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/3/733a108693f6a4ec117c9f11d291e70bcdf098ab.jpeg)

Is there something obvious we’re doing wrong or is there an issue with the integration that we’re missing? Any help or troubleshooting would be appreciated!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 25, 2023, 5:14pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/2 "2023-04-25T17:14:20Z")

</div>

Hi, @EKight 👋 Thanks for your question. I’d like to invite some of our community members to the conversation. Hey, @Anton @piersg @ChrisoKlepke @LMeert, do you have any experience you can share with @EKight?

Thank you for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [April 26, 2023, 6:35am UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/3 "2023-04-26T06:35:32Z")

</div>

Hi @EKight,

I’d do it like this

HTML:

```lia-code-sample
{% if contact.hs_lifecyclestage_lead_date == "lifecycle_a" %}
 {%- set image_path = module.images.image_1.src -%}
 {%- set image_url = module.urls.url_1.href -%}
{% elif contact.hs_lifecyclestage_lead_date == "lifecycle_b" %}
 {%- set image_path = module.images.image_2.src -%}
 {%- set image_url = module.urls.url_2.href -%}
{% elif contact.hs_lifecyclestage_lead_date == "lifecycle_c" %}
 {%- set image_path = module.images.image_3.src -%}
 {%- set image_url = module.urls.url_3.href -%}
{% else %} {# set dropback image and path if the lifecycle is unknown #}
 {%- set image_path = module.images.image_dropback.src -%}
 {%- set image_url = module.urls.url_dropback.href -%}
{% endif %}
{# replace 'hs_lifecyclestage_lead_date' with the name of your property and 'lifecycle_*' with the correct option/value #}

<a href="{{ image_url }}">
 <img src="{{ image_path }}">
</a>

```

 ![Anton_2-1682490541107.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/9/196298c1ed52f3dd0931da2469aa123c1f011501.png)

you can find the correct name of the property if you open the property in the settings or add it as a personalization token to a rich-text and open the source-code view

Also - you don’t really need all those images and url options in the module. You can set them to fixed values if you don’t want to modify them in the email-creator. The code would look like this

```lia-code-sample
{% if contact.hs_lifecyclestage_lead_date == "lifecycle_a" %}
 {%- set image_path = "path_to_first_image" -%}
 {%- set image_url = "link_that_should_be_opened_by_clicking_this_image" -%}
{% elif contact.hs_lifecyclestage_lead_date == "lifecycle_b" %}
 {%- set image_path = "path_to_second_image" -%}
 {%- set image_url = "link_that_should_be_opened_by_clicking_this_image" -%}
{% elif contact.hs_lifecyclestage_lead_date == "lifecycle_c" %}
 {%- set image_path = "path_to_third_image" -%}
 {%- set image_url = "link_that_should_be_opened_by_clicking_this_image" -%}
{% else %} {# set dropback image and path if the lifecycle is unknown #}
 {%- set image_path = "path_to_dropback_image" -%}
 {%- set image_url = "link_that_should_be_opened_by_clicking_this_image" -%}
{% endif %}
{# replace 'hs_lifecyclestage_lead_date' with the name of your property and 'lifecycle_*' with the correct option/value #}

```

Note: I haven’t tried it

best,

Anton

---

<div class="post-metadata">

**Author:** ![EKight](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@EKight](https://community.hubspot.com/u/EKight)\
**Post date:** [April 28, 2023, 6:30pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/4 "2023-04-28T18:30:21Z")

</div>

Thank you, Anton! We tried your code replacing those sections with the name of our property and the correct values, the image path and the url along with a default image, and it’s still not displaying for our contacts the way it should.

{% if contact.fcra\_lead\_status == “1\_New” %}  
{%- set image\_path = “[https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Talk%20with%20a%20paralegal%20progress%20bar.jpg](https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Talk%20with%20a%20paralegal%20progress%20bar.jpg)” -%}  
{%- set image\_url = “[Credit Report Lawyer For Fixing Errors | McCarthy Law PLC](https://mccarthylawyer.com/credit-report-errors/)” -%}  
{% elif contact.fcra\_lead\_status == “1.5\_Attempting\_to\_contact” %}  
{%- set image\_path = “[https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Talk%20with%20a%20paralegal%20progress%20bar.jpg](https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Talk%20with%20a%20paralegal%20progress%20bar.jpg)” -%}  
{%- set image\_url = “[Credit Report Lawyer For Fixing Errors | McCarthy Law PLC](https://mccarthylawyer.com/credit-report-errors/)” -%}  
{% elif contact.fcra\_lead\_status == “2\_Waiting\_Reports” %}  
{%- set image\_path = “[https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Credit%20report%20progress%20bar.jpg](https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Credit%20report%20progress%20bar.jpg)” -%}  
{%- set image\_url = “[Credit Report Lawyer For Fixing Errors | McCarthy Law PLC](https://mccarthylawyer.com/credit-report-errors/)” -%}  
{% elif contact.fcra\_lead\_status == “4.5\_Review\_for\_Dispute” %}  
{%- set image\_path = “[https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Attorney%20Review%20Progress%20Bar.jpg](https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Attorney%20Review%20Progress%20Bar.jpg)” -%}  
{%- set image\_url = “[Credit Report Lawyer For Fixing Errors | McCarthy Law PLC](https://mccarthylawyer.com/credit-report-errors/)” -%}  
{% else %} {# set dropback image and path if the lifecycle is unknown #}  
{%- set image\_path = “[https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Credit%20report%20progress%20bar.jpg](https://9314049.fs1.hubspotusercontent-na1.net/hubfs/9314049/Credit%20report%20progress%20bar.jpg)” -%}  
{%- set image\_url = “[Credit Report Lawyer For Fixing Errors | McCarthy Law PLC](https://mccarthylawyer.com/credit-report-errors/)” -%}  
{% endif %}  
{# replace ‘hs\_lifecyclestage\_lead\_date’ with the name of your property and ‘lifecycle\_\*’ with the correct option/value #}

---

<div class="post-metadata">

**Author:** ![EKight](https://avatars.discourse-cdn.com/v4/letter/e/7cd45c/32.png) [@EKight](https://community.hubspot.com/u/EKight)\
**Post date:** [May 1, 2023, 4:10pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/5 "2023-05-01T16:10:40Z")

</div>

Got it working! Did some dynamic debugging of the variables (contact email, fcra lead status, and status ID) and had a test email pull in those values to see if anything was populating. This is the code we pasted into an HTML block to test this in a test email:

\</h3\>  
\<ul\>  
\<li\>contact.email: {{ contact.email }}\</li\>  
\<li\>sendId: {{ message.sendID }}\</li\>  
\<li\>fcra\_lead\_status: {{ contact.fcra\_lead\_status }}\</li\>  
\</ul\>

The contact email displayed the correct value but the fcra lead status value was blank. We used the same format as the email variable {{ contact.BLANK }} for our fcra lead status variable {{ contact.fcra\_lead\_status }} and it started populating the current status of the test contact we sent a test email to. We swapped that text in every location that variable was listed and our images started displaying correctly.

Here is the new code that works:

\<a href=“[https://mi.mccarthylawyer.com/p/cp/53d56e6b6d616e2c/c?mi\_u=](https://mi.mccarthylawyer.com/p/cp/53d56e6b6d616e2c/c?mi_u=){{ contact.email }}&mi\_ign={{ sendID }}&mi\_fcraleadstatus={{ contact.fcra\_lead\_status }}&url=https%3A%2F%[2Fmi.mccarthylawyer.com](http://2Fmi.mccarthylawyer.com)%2Fp%2Frp%2F2502da306657f8ec%2Furl” style=“display: block”\>  
\<img  
alt=“Display images to show real-time content”  
style=“border: 0; display: block;”  
border=“0”  
width=“600”  
src=“[https://mi.mccarthylawyer.com/p/rp/2502da306657f8ec.png?mi\_u=](https://mi.mccarthylawyer.com/p/rp/2502da306657f8ec.png?mi_u=){{ contact.email }}&mi\_ign={{ sendID }}&mi\_fcraleadstatus={{ contact.fcra\_lead\_status }}”  
/\>  
\</a\>

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 1, 2023, 4:54pm UTC](https://community.hubspot.com/t/question-about-custom-code-module/79935/6 "2023-05-01T16:54:51Z")

</div>

Hey, @EKight! Thank you very much for sticking with this post. And for taking the time to post how you troubleshot and resolved the remaining issues.

Per usual, you’re legendary @Anton and so appreciated 🙌

Best,

Jaycee
