4 Replies Latest reply on Apr 25, 2014 7:18 AM by af03dad167e46eb4803ce730cc12610c4dc6019f

    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
        • 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


          • 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
            • Re: Email Script - "starts with" operator
              Calvin Lam
              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
              1 of 1 people found this helpful
              • Re: Email Script - "starts with" operator
                Thanks a lot, Calvin! That's exactly what I was looking for!