Printing a paragraph for every condition met

djb
Level 1
Level 1

Printing a paragraph for every condition met

Hi All! New to Maketo and looking into VLT coding but cant seem to get something working.

Is the below possible in VLT code.

 

Person A is is interested in studying Nursing, Marketing and Design

(there are 600 other courses hence why I'm trying to do it in a VS)

 

Instead of sending 3 welcome emails, we would like to send one welcome email but include a paragraph of text about each course.

 

I suspect a a loop or Switch statement would be best, but if anyone has a better way of doing this, please let me know and i will look into it.

 

So the email person A would receive, would look like this:

 

Banner

--------------

Default text

--------------

Nursing text

--------------

Marketing text

--------------

Design text

--------------

Email sign off

 

 

Thanks, Dan

 

5 REPLIES 5
Darshil_Shah1
Level 10 - Community Advisor

Re: Printing a paragraph for every condition met

I think this can be acheived by conditional #if blocks for checking the AOI values for a person to populate the email content. Also, wouldn't the email become too long if person is interested in say like 10 courses? Or, do you have an upper limit for the AOI values (i.e., courses) that a person can have at a time? From what I can understand based on your post is that you've 600 possible AOI values.

 

If required, velocity can also pick a set max. number of AOI values for populating the respective content in the email in-case a person has a lot of AOIs. Ex. pick three AOIs and populate the respective AOI content in the emails in-case the person has like 10 AOI values.

 

Best,
Darshil
SanfordWhiteman
Level 10 - Community Moderator

Re: Printing a paragraph for every condition met


Hi All! New to Maketo and looking into VLT coding but cant seem to get something working.

VTL (Velocity Template Language), not VLT. 🙂

 

 


(there are 600 other courses hence why I'm trying to do it in a VS)

How are these 600 courses stored in Marketo? This is a critical part of the scenario.

 


I suspect a a loop or Switch statement would be best

Velocity doesn't have a switch() per se (in the sense of cases with fallthrough). It has #if/#elseif/#elseif but from your description the cases are all independent. So they may just be a lot of #if/#end conditions. Of course you don't want to repeat content (esp. because there's a max size of the whole token code) so detailed examples are necessary.

 

As @Darshil_Shah1 rightly mentions, you may want to keep track of how many matches you have and set a max # to output.

djb
Level 1
Level 1

Re: Printing a paragraph for every condition met

Ah yes, VTL, apologizes!

 

We have a heavy custom build due to the way data is in MSD, the course data is purely a text field within a Microsoft custom field tab. We have always know about these limitations as we have so many courses and this was deemed the best way to get the data into the system. Obvious segmentation are out of the question with the 100 limit.

 

Each person can only apply for a maximum of 3 courses

 

Data within Marketo looks like this, within the Microsoft custom field tab

 

Trying to work it out but I think the #if/#end is the best way to go, trouble will be if i hit the token max size which is 100kb i believe. Is there anywhere where it states how big the script size is?

 

Thanks for your reply!

SanfordWhiteman
Level 10 - Community Moderator

Re: Printing a paragraph for every condition met


Trying to work it out but I think the #if/#end is the best way to go, trouble will be if i hit the token max size which is 100kb i believe. Is there anywhere where it states how big the script size is?


Do you mean how many bytes your code takes up as you type? No, you'd have to do the math yourself.

 

Like I said the question is going to be how different each block is. If you have 600 text blocks with absolutely nothing in common, then you'd be limited to about 150 bytes for each (leaving room for the logic itself). That's pretty darn short. But you'd have to tell us what you're planning to output.

 

Jo_Pitts1
Level 10 - Community Advisor

Re: Printing a paragraph for every condition met

What about this:

  • Create a text token for each paragraph text.  Name them meaningfully (intro_text_nursing, intro_text_marketing etc.)
  • Create a velocity token that:
    • has a map from each course to the text token name
    • loops through the courses of interest, checks in the map, retrieves the text token, and outputs it

Cheers

Jo