We have created a program that allows you to view and identify the subscription of an account based on a series of tokens that concern the calculation of points;
In the Dev area we used this Token:
#if($listOne)
#set( $intMax = $math.sub($listOne.size(),1) )
#foreach( $num in [ $intMax..0 ] )
#if(${listOne.get($num)} && ${listOne.get($num).listTwo.get(0)} )
${listOne.get($num).listTwo.get(0).name}
#break
#end
#end
#end
And we used the same token in Production Area ;
Dev Area :
Shows this results for the Activity Log of the user :
The results of the Campaign, in this case the emails are sent and delivered :
Moreover we have obtained the same results through the use of a batch campaign activated with a Run Once while in production with the same operation we have not obtained any results.
Production Area :
once we changed users in production we tested the campaign using the same Token but we found different results, we obtained this results for the Activity Log of the user :
While the results of the campaign are as follows:
Why, since there are no differences between the two environments, we find this error in sending emails: None.get ?
There's not really enough information here because you haven't provided examples of your lists.
Even without that, I can say almost certainly that your code is buggy because you're using Boolean conditions (#if($listOne)) on List objects, which are always truthy regardless of their contents. It's impossible to have a falsy List. (A null is falsy in Velocity, but that's not the same thing, and you should check for null explicitly.)
Also, you don't need to #foreach over indexes in a List to do a reverse scan, you can sort the List and use a standard iterator.
Most likely the direct cause of that None.get is you didn't check off necessary objects in the tree in Script Editor, but you should also fix the code.
Thanks a lot for the answer.
We changed the token like this:
#if(($listOne) && ($listOne.size() > 0))
#set( $intMax = $math.sub($listOne.size(),1) )
#foreach( $num in [ $intMax..0 ] )
#if($listOne.get($num) && ${listOne.get($num).listTwo.get(0) )
$listOne.get($num).listTwo.get(0).name}
#break
#end
#end
#end
Unfortunately after modifying the token and checking the fields of the tree in the Script Editor; I get the same result:
Thanks in advance for your cooperation