Skip to main content
Level 4
Sep 8, 2025 1:23 PM UTC
Solved

Substring Helper Function in HTML not working

Hello, 

 

I have the following code in my HTML I'm trying to use. This code looks for a Campaign Name attribute and applies the corresponding couponID. However, when I try to save this code, I get an "invalid helper substr" error. 

 

{{#each profile._*********.walletInfo.couponDetails as |coupon|}} {%#if contains(coupon.campaignName,"NA_EM_2025_Coupon_Launch" ) %} {% substr(coupon.couponId,38) %} {%else%} No Valid Coupon Available {%/if%}{{/each}}
 
Please advise
 
SatheeskannaK
SatheeskannaKAccepted solution
Adobe Champion, Community Advisor, UG Leader
Sep 8, 2025 2:55 PM UTC

@montezh2001 the substr function is missing the syntax. try along these lines,

{{#each profile._*********.walletInfo.couponDetails as |coupon|}}
{%#if contains(coupon.campaignName,"NA_EM_2025_Coupon_Launch") %}
{%= substr(coupon.couponId,0,2) %}
{%else%} No Valid Coupon Available {%/if%}
{{/each}}

 

Thanks, Sathees

2 replies

SatheeskannaK
Adobe Champion, Community Advisor, UG Leader
SatheeskannaKAdobe Champion, Community Advisor, UG LeaderAccepted solution
Adobe Champion, Community Advisor, UG Leader
Sep 8, 2025 2:55 PM UTC

@montezh2001 the substr function is missing the syntax. try along these lines,

{{#each profile._*********.walletInfo.couponDetails as |coupon|}}
{%#if contains(coupon.campaignName,"NA_EM_2025_Coupon_Launch") %}
{%= substr(coupon.couponId,0,2) %}
{%else%} No Valid Coupon Available {%/if%}
{{/each}}

 

Translate
Thanks, Sathees
Level 2
Sep 8, 2025 9:28 PM UTC

Thank you @satheeskannak .

 

This worked, despite the documentation stating having the ending index is an option. 

Translate