Runtime verified Differs from official docs Test scripts included

Returns part of a string, counting positions from 1.

Syntax

{{substring subject start [length]}}

Returns string.

Parameters

Name Type Required Description
subject string Yes Source string.
start integer Yes Starting position. Position 1 is the first character.
length integer No Number of characters to extract.

Example

Tested in a Marketing Cloud Next email on 2026-11-22:

  • {{substring "abcdef" 2 3}} renders bcd, as documented.
  • {{{substring "<i>abc</i>" 1 6}}} renders com.salesforce.e360.messaging.rendering.helper.HandlebarResultWrapper@539b5bf2.
Show Next test script
<!-- Marketing Cloud Next test script for the substring helper. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[bcd] got=[{{substring "abcdef" 2 3}}]</p>
<p>c2 expect=[com.salesforce.e360.messaging.rendering.helper.HandlebarResultWrapper@539b5bf2] got=[{{{substring "<i>abc</i>" 1 6}}}]</p>

Differs from official docs

  • The reference does not say that the helper cannot be used with triple braces, the usual Handlebars way to output a value without HTML escaping. In Marketing Cloud Next (tested 2026-11-22): {{{substring "<i>abc</i>" 1 6}}} rendered com.salesforce.e360.messaging.rendering.helper.HandlebarResultWrapper@539b5bf2 instead of the text. With double braces the helper works: {{substring "abcdef" 2 3}} rendered bcd. Details

Marketing Cloud Next

See also