SOLVED

Re: Email Script - "starts with" operator

Go to solution
Anonymous
Not applicable

Email Script - "starts with" operator

Hi all,

I'm trying to create a logic in an email script token that prints a from-email-address based on the Postcode field. So it should be something like:

#if ("$lead.PostalCode" starts with "1")
salesrep1@company.com
#else
salesrep2@company.com
#end

Any idea on how to accomplish that? I've read through the Velocity User Guide but didn't find anything useful. Oh, and postcode is a text field in our install so it seems that something like 

#if ("$lead.PostalCode" < "50000")

seems not to work.

Thanks,
Michael
Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
Calvin_Lam
Level 4

Re: Email Script - "starts with" operator

All email scripting variables are String objects which can manipulated by methods here - http://docs.oracle.com/javase/6/docs/api/java/lang/String.html

Below is the modified code that will work:

#set ( $code = ${lead.PostalCode} )    ##set the variable code to equal to the lead's postal code.  This is not necessary.  Just a personal preference to shorten the name
#if ( $code.startsWith("1") )
    salesrep1@company.com
#elseif ( $code.startsWith("2") )
    salesrep2@company.com
#else    ##any other leads that don't match
    callmemaybe@company.com
#end

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Re: Email Script - "starts with" operator

Hi Michael,

Without any information on your company structure and processes, I could think of already two ways of dealing with this:

1/ I suppose the postal code field is a unique value. You could have a data management campaign running which inserts the data in a field containing the sales rep e-mail (for example: a custom field named Sales Rep Email Address) based on the data in the postal code field. 

Example: 

If field: 'Postal code' is '5000' --> Change Data Value in field 'Sales Rep Email Address' to 'SalesRep1@company.com'

In this case you can just set up an e-mail with a token {{sales rep email address}}.

2/ use segmentation and dynamic content again based on the 'postal code' field = although it could be tedious to use this approach and you might need an intermediate data management step to make things easier, for example:

If sales rep 1 is currently responsible for the postal code areas 5000, 5001, 5002, 5003 and 5004, you might want to create a region field which consists of these postal codes (an additional field), which you can use for your segmentation and as such for your dynamic content

= although I would personally propose you first check out option 1.

Hope this is an answer to your question.

Best,

Jonas


Anonymous
Not applicable

Re: Email Script - "starts with" operator

Hi Jonas,

the more I think about your idea, the more I like it. When first thinking about it, I was hesitant to create a new field, as my process touches only a small fragment of our database, so I wanted to keep is as local as possible. But now I think this auxiliary field would really serve my purpose the best.

Thanks for your reply!

Michael
Calvin_Lam
Level 4

Re: Email Script - "starts with" operator

All email scripting variables are String objects which can manipulated by methods here - http://docs.oracle.com/javase/6/docs/api/java/lang/String.html

Below is the modified code that will work:

#set ( $code = ${lead.PostalCode} )    ##set the variable code to equal to the lead's postal code.  This is not necessary.  Just a personal preference to shorten the name
#if ( $code.startsWith("1") )
    salesrep1@company.com
#elseif ( $code.startsWith("2") )
    salesrep2@company.com
#else    ##any other leads that don't match
    callmemaybe@company.com
#end
Anonymous
Not applicable

Re: Email Script - "starts with" operator

Thanks a lot, Calvin! That's exactly what I was looking for!