Hi everyone,
I like to check the email address for specific domains using velocity/email scripting. But for some reasons it is not working for me.
Attempt 1 - Using contains
#set($mail = "wolfram.lotz@xy-c.com")
$mail.contains("xy-c.com")
this works fine
#set($mail= "{{lead.Email Address}}")
$mail.contains("xy-c.com")
$mail
contains is always false
but $mail output shows the correct domain
Attempt 1 - Using split (to check later for equal)
#set($mail = "wolfram.lotz@xy-c.com")
#set($domain= $mail.split("@"))
$domain[1]
This works fine. Domain is shown correct.
#set($mail = "{{lead.Email Address:default=edit me}}")
#set($address= $mail.split("@"))
$address[0]
This split does not work. It shows the whole email instead of just the part before the @
Note: I'm checking this within the email, which is why you see ":default=edit me" here.
I checked as well the following post: https://nation.marketo.com/t5/product-discussions/velocity-splitting-a-string-into-an-array/td-p/144...
#set ($string = "ABCD/GIST/SPIT")
#set ($output = $string.split('/'))
$output[0]
That code is working totally fine as well. But even trying to use a unicode u0040 instead of the @-char does not change anything.
Does anybody have an idea?
Nothing you’re trying to do with Velocity in the email body (not in a {{my.token}}) is supported. There are innumerable unexpected behaviors when attempting this, and no guarantee that something that works today will work tomorrow. In particular I can’t imagine why you wouldn’t use an actual Email Script {{my.token}} to parse the domain.
Hi Sanford,
reason is that this has to happen before my-tokens are exchanged from Marketo.
But at the end it's the question - can you imagine why a given string is processet like expected but a string set via token is not?
Is it maybe a question of processing order? Or maybe a question for the format/coding the token result is delivered?
reason is that this has to happen before my-tokens are exchanged from Marketo.
I don’t understand what this means. Exchanged?
But at the end it's the question - can you imagine why a given string is processet like expected but a string set via token is not?
Because you’re expecting a certain order of processing which is not supported.
Hi @SanfordWhiteman
answer was somewhere in the middel. Hint was the email link tracking order.
Yes, it is possible to use "contains" and "split" in an email script AND it is possible to use them in an template (for now).
BUT first the velocity code is processed and after it the tokens are exchanged. So by this it is not possible to analyse token-content on template level als the code would analyse the token-label but not the information the token will deliver.
Thanks
The order in which {{lead.token}} values are interpolated (which I think is what you mean by “exchanged”) and non-token Velocity code is executed is not specified, meaning it cannot be relied upon.
P.S. the way to match a domain is $lead.Email.endsWith("@example.com"), not $lead.Email.contains().
Thank you