Hi Community!
I'm hoping someone could help me with an issue I'm having with a velocity script token. After I add the token to an email, I receive an error when I try to approve.
Here's the code I've set up:
#set ($string = "$OpportunityList.get(0).Document_Links__c" )
#set ($output = $string.split('\n'))
#set ($docLa = "$output[0]" )
#set ($docLb = "$output[1]" )
The variables are then used in separate script tokens and added to the email to display the output data.
{{my.doclink-url-1}}
In the Email:
<a href="{{my.doclink-url-1}}" style="font-weight: bold;">{{my.Dynamic-DisplayBrandNameA}} Regular Guarantee</a> <br /><br />
<a href="{{my.doclink-url-2}}" style="font-weight: bold;">{{my.Dynamic-DisplayBrandNameA}} Regular Terms</a>
This code was working for a time then all the sudden stopped recently (I'm guessing maybe it shouldn't have worked the first time)
Interestingly, if I remove the last line in the code, I can approve the email normally.
Any help would be much appreciated! Thank you!!
Solved! Go to Solution.
Simple — the error tells you exactly what’s happening.
You’re trying to access the 1st index in the array without checking if it has a 1st index. Accessing a nonexistent index is a fatal error. You should make sure the Opportunity list is non-empty and that the split string has the expected size.
Some additional Velocity pointers:
Simple — the error tells you exactly what’s happening.
You’re trying to access the 1st index in the array without checking if it has a 1st index. Accessing a nonexistent index is a fatal error. You should make sure the Opportunity list is non-empty and that the split string has the expected size.
Some additional Velocity pointers:
Thank you so much Sanford!
I've updated the code, and now the issue appears to be resolved!
updated code:
#if( !$OpportunityList.Document_Links__c.isEmpty() )
#set ($interestingOpptyDocLinks = $OpportunityList.get(0).Document_Links__c )
#set ($output = $interestingOpptyDocLinks.split('\n'))
#set ($docLa = $output[0] )
#set ($docLb = $output[1] )
#end