SOLVED

Re: Email velocity token

Go to solution
Jay00031987
Level 4

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
SanfordWhiteman
Level 10 - Community Moderator

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

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

 

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

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

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

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 ____________________________________.

Jay00031987
Level 4

I want to check empty value in custom objects(field xyz) as well as empty in lead standard ( i.e. not in custom table).

I am not checking non empty for the field xyz property .

And abc field is link id with lead standard in Marketo. which is related with xyz as a child field.

And for empty value in custom objects field xzy I want to display zero and empty value for lead  standard ( i.e. not in custom table). I want to display zero here also.

For, non empty value field xyz I want to display value in email but no checking is needed only display value.

Jay
SanfordWhiteman
Level 10 - Community Moderator

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.

Jay00031987
Level 4

Hi San,

I have implemented after that email is getting soft bounced with below error

System send failure: Velocity transform failed: ; The nested exception is: org.apache.velocity.exception.ParseErrorException: Encountered "

Jay
SanfordWhiteman
Level 10 - Community Moderator

I have no idea what your full token looks like.

 

The pointers I've given you are just individual lines, they don't even have closing #end  statements!

SanfordWhiteman
Level 10 - Community Moderator

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

Jay00031987
Level 4

please share link where I have to check

Jay
SanfordWhiteman
Level 10 - Community Moderator

syntax_vtl.png

 

Jay00031987
Level 4

ok

Jay