Re: Velocity Scripting referencing a custom object - Error message I can't google!

Benjinc
Level 2

Velocity Scripting referencing a custom object - Error message I can't google!

Hi,
I am receiving the below error message when trying to reference a custom object in a script.

 

Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>String index out of range: -1 near</p> <div><pre ></pre></div>

The code I have in place is:

<table style="border-spacing: 0; border-collapse: collapse; width: 600px;">
#foreach ($202407DCPG in $2024DCPG_cList)
<tr>
<td style="padding: 4px; font-family: arial; border-collapse: collapse !important; border: 1px solid black">
${202407DCPG.brokerContactEmail}
</td>
<td style="padding: 4px; border-collapse: collapse; border: 1px solid black">
${202407DCPG.sponsorName}
</td>
</tr>
#end
</table>



I have the appropriate fields checked on the right hand menu.
I have tried doing a more simple pull, outside of the table format too and get a similar error.

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting referencing a custom object - Error message I can't google!

Remember to use the Syntax Highlighter (“Insert/Edit Code Sample” on the button bar) so code is readable. I edited your post this time.

 

I would expect an error from this code because Velocity references are not allowed to start with numbers. But the error wouldn’t be the one you’ve posted here, it would be an error calling out the arguments to #foreach.

 

Is this the only Velocity {{my.token}} in the entire email?

 

What happens if you start a fresh email containing only a {{my.token}} with the following code (and of course the CO checked off in the tree):

 

${2024DCPG_cList}

 

 

Benjinc
Level 2

Re: Velocity Scripting referencing a custom object - Error message I can't google!

Thanks Sandford


I have set up a completely fresh email, containing the token call for just the below script

${dCPG202407_cList}

Note I set up a new object starting without numbers.

 

For further context, "Policy Number" is the Key (set up as a string) and I am linking it to the lead table connect "Broker Contact Email" with "Email Address"

 

We have a SFDC CRM connection

There was another my.token in the previous email, I received the same error, with this simple set up though with just this token running:

 

 Cannot get email content- <div>An error occurred when procesing the email Body! </div> <p>String index out of range: -1 near</p> <div><pre ></pre></div>

To make sure Im not doing anything v stupid below is a screen shot of how I've set up the token!


Capture.PNG

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity Scripting referencing a custom object - Error message I can't google!

@Benjinc please PM so we can look at this over a screenshare. I think we’re about to find a bug that’s outside the scope of what you’ve posted (which looks fine).