SOLVED

Email velocity token

Go to solution
Jay00031987
Level 4

Email velocity token

I have created custom objects  named as CO and using custom objects (CO)field as a email script token in email for the field created "role". I want to populate based on condition if part of custom objects display role.

Problem - Using if condition code it jumps to else condition only. 

 

Jay
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token

You just changed your spec: you didn't mention anything about Lead properties before.

 

In any case, the correct way to check whether a property value is empty is, as noted above:

 

#if( $someObject.somePropertyName.isEmpty() )

 

That $someobject could be the built-in $lead or it could be a Custom Object record in your list of Custom Objects, as you're #foreach-ing over the list. When you do 

 

#foreach( $someItem in $someList )

 

then, inside the #foreach, $someItem is automatically set to the current record as you iterate, record [0], record [1], record [2], and so on.

View solution in original post

13 REPLIES 13
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token

Please highlight your code using the syntax highlighter (choose Java as the language). Then we'll continue.

Jay00031987
Level 4

Re: Email velocity token

please share link where I have to check

Jay
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token

syntax_vtl.png

 

Jay00031987
Level 4

Re: Email velocity token

ok

Jay
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token

To begin with, your code isn't valid Velocity. You must have taken empty() from another language. The correct way to check in Velocity/Java is

 

#if( $someReference.isEmpty() )

 

Then you're just gettting the first item in the list of loyaltypoints. Don't you want to check if any items in the list have a non-empty totalActual property? Why would you just check one? And what is supposed to happen if more than one item has a non-empty totalActual?

Jay00031987
Level 4

Re: Email velocity token

 

1. created variable $a to store value  and

2. In if condition checking   value is not empty than print the value 

 

Jay
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token


1. in Email Script, I want to print the ${loyaltypoints_cList.get(0).totalActual}  value

Please don't try to express your business requirements in code, as you aren't a coder.

 

Explain in plain language.

Jay00031987
Level 4

Re: Email velocity token

Hi San,

Actually, I want to access one field from custom objects i.e. XYZ

but when I am using custom objects field XYZ  with If condition it jumps to else condition only.

Hence, In result I am getting error with default value as script token  in email for those lead which is not in custom objects. And exact value for lead whose is in custom object. So, I want to fix the vale ZERO for non-custom objects leads

Jay
SanfordWhiteman
Level 10 - Community Moderator

Re: Email velocity token


Actually, I want to access one field from custom objects i.e. XYZ

but when I am using custom objects field XYZ  with If condition it jumps to else condition only.

Hence, In result I am getting error with default value as script token  in email for those lead which is not in custom objects.


Every Custom Object record in the list of Custom Objects has a set of properties (fields). The keys are the same for every record, but the values certainly do not have to be the same.

 

So "one field from custom objects" isn't clear enough.

 

Fill in the blank:

 

When iterating over the list of Custom Objects, for each item in the list, I want to ____________________________________.