String index out of range: -1 for Custom Object Lookup | Community
Skip to main content
Stephen_Baker2
Level 2
March 5, 2018
Solved

String index out of range: -1 for Custom Object Lookup

  • March 5, 2018
  • 1 reply
  • 8398 views

Attached an image of all parts combined.

I have a test object with a currency property for a lead but attempting to grab it in a token is resulting in an index error.

* custom object field is of type currency

* it returns index error no matter what get() value is set to

* verified the property exists under the custom object for the lead used in preview

* removing { } from the object reference doesn't change the error (don't think this matters)

* this is a one-to-many relationship object that dedupes and links by Email Address

* expected outcome is token pulls in a single value from the custom object for the target person (custom object has one line item per email address)

Error:

Cannot get email content-

An error occurred when procesing the email Rendered_Email_Velocity_Error_Area_?!

String index out of range: -1 near

?

Code:

#set ( $render = $2018TaxSeason_cList.get(0).preApprovalAmount )

$render

Any insight greatly appreciated, am exhausted in efforts to figure out how custom objects work. Docs state it pulls in a list of up to 10 items by default, not sure in a one-to-many relationship if this means it pulls in 10 top leads or 10 top properties for each lead when the token runs.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Stephen_Baker2

And does this same behavior exist with another CO, like Vehicle Inquiry?


Heh. Noticed it was changing syntax highlighting when switching to another object.

Wasn't working with the year (number) in the object name. Excluding year in a new object fixed the issue.

Probably shouldn't let you save objects with integers but ¯\_(ツ)_/¯

$context["loweredCredit_cList"]

$context["loweredCredit_cList"].class

${loweredCredit_cList.get(0).emailAddress}

${loweredCredit_cList.get(0).minimumDown}

${loweredCredit_cList.get(0).preApprovedAmount}

1 reply

SanfordWhiteman
Level 10
March 5, 2018

Something interesting here that I'll mention in a moment, if my suspicions are correct.

What output do you get from this token (making sure to check off the CO and the property in the tree):

$context["2018TaxSeason_cList"]

$context["2018TaxSeason_cList"].class

Stephen_Baker2
Level 2
March 5, 2018

Oddly enough or to be expected: it returns the same error.

SanfordWhiteman
Level 10
March 5, 2018

Do you still have the original token, or any other Velocity token, in this email?