SOLVED

How to increment a token

Go to solution
MarketingMe
Level 2

How to increment a token

Is there a way to have a token field  and then have another token that's +30 days from the previous token field?  For example, I have this situation in an email:

Your membership expired on {{lead.Membership End Date:default=end date}}; however, if you renew before <<GracePeriodEndDate>> we'll be happy to extend your  USD renewal rate.

The "Grace Period  End Date" is 30 days after the lead: membership end date.  Is there a way to create a token for Grace Period End Date that is 30 days after the lead: membership end date? 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: How to increment a token

You can use Velocity to just display 30 days from now. Follow the when-is-7-days-from-today example at https://blog.teknkl.com/velocity-days-and-weeks/.

View solution in original post

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: How to increment a token

Can you? Yes. But why do you need a whole separate, permanent field? Do you always just need to output today-plus-30d in an email, or would you also be using the field in filters?
MarketingMe
Level 2

Re: How to increment a token

I don't think I need a separate permanent field - just a token in an email that can add 30 days to the previous token {{lead.Membership End Date}}.  I'm using "Membership End Date in past 0 days" as my smart list filter to pull those whose membership expired today.

If you have a better solution, please share.  I know there's about 10 ways to do the same thing in Marketo and some ways are better than others!

Thank you

SanfordWhiteman
Level 10 - Community Moderator

Re: How to increment a token

You can use Velocity to just display 30 days from now. Follow the when-is-7-days-from-today example at https://blog.teknkl.com/velocity-days-and-weeks/.

View solution in original post

MarketingMe
Level 2

Re: How to increment a token

Hi Sanford,

I have never done a velocity script token.  I chose the Email Script token option and pasted in the copy you provided in your link.  I changed the 7's to 30's.  Does this make sense?  I added the token to my email and it didn't work. 

Velocity Script:

 

$calNow.add($calConst.DATE,30)
#set( $FRIENDLY_24H_DATETIME_WITH_FRIENDLY_TZ = "MMM dd, yyyy HH:mm z" )
Our promo expires 30 days from today, which is
${date.format(
$FRIENDLY_24H_DATETIME_WITH_FRIENDLY_TZ,
$calNow,
$defaultLocale,
$defaultTimeZone
)}

 

Email test in Edit mode:

Your membership expired on {{lead.Membership End Date:default=end date}}; however, if you renew before {{my.30 Day Grace Period:default=edit me}} we'll be happy to extend your renewal rate. Don't miss out on valuable information and significant discounts on training and events!

 

Email test in preview mode with View by: Person email address added:

Your membership expired on 2022-01-22; however, if you renew before $calNow.add($calConst.DATE,30) Our promo expires 30 days from today, which is ${date.format( $FRIENDLY_24H_DATETIME_WITH_FRIENDLY_TZ, $calNow, $defaultLocale, $defaultTimeZone )} we'll be happy to extend your renewal rate. Don't miss out on valuable information and significant discounts on training and events!

 

I want the script token to add the date 30 days from the day I send the email (or 30 days past the membership expired date).  I'll be sending this email each day to all those whose memberships expired that day. 

 

SanfordWhiteman
Level 10 - Community Moderator

Re: How to increment a token

You need to include the common Velocity includes as described in the intro section — be sure to read and digest the intro before using the examples.
MarketingMe
Level 2

Re: How to increment a token

Sanford, you're going to make my head explode - LOL.  I've never done any kind of scripting so this has been quite the learning curve. 

The good new is I finally got the token to work!  It's pulling in the date 30 days from today, however, it's putting it in the "friendly" date format, which is great, but it doesn't match the previous token date {{lead.Membership End Date}} that looks like this: 2022-01-22.

Email copy: 

Your membership expired on 2022-01-22; however, if you renew before Feb 25, 2021 we'll be happy to extend your renewal rate.

 

Can  you please tell me how I can apply this "friendly" date format to the lead.membership end date token? 

Thank you!

SanfordWhiteman
Level 10 - Community Moderator

Re: How to increment a token


Can  you please tell me how I can apply this "friendly" date format to the lead.membership end date token? 

Thank you!


You'd need to output the Membership End Date from Velocity as well so you can choose the format.

 

Which means you first need to cast the field, which is a String to start with, into a true Date. If you open another thread I can show you there.