SOLVED

Need to include form selections in confirmation email and change the name of the fields

Go to solution
Ben_Cooper
Level 2

Re: Need to include form selections in confirmation email and change the name of the fields

Where exactly do I add that in the token?

SanfordWhiteman
Level 10 - Community Moderator

Re: Need to include form selections in confirmation email and change the name of the fields

Top or bottom, just seeing the raw value of that field.

Ben_Cooper
Level 2

Re: Need to include form selections in confirmation email and change the name of the fields

By adding that line, I get this in the body of the email:

sessionBooks: 1

SanfordWhiteman
Level 10 - Community Moderator

Re: Need to include form selections in confirmation email and change the name of the fields

Looks like you have a typo.

$fieldin

should be

$field in

Ben_Cooper
Level 2

Re: Need to include form selections in confirmation email and change the name of the fields

Hi Sanford,

That did it! Thank you.

One last question in relation to this if that's ok.

The script ultimately has multiple fields that a user can select and be set as booleanfriendlies. When a user selects more than one choice on the form, the script runs, they receive and email, and all of their selections are crammed together. Is there a way to put each selection on a new line when the email is delivered? I am looking at Apache's Velocity docs and having a hard time trying to find it. 

Here is what it currently looks like in the body of the email:

Books: Thursday, February 1, 11:00 – 11:20amDocs: Thursday, February 1, 2:00 – 2:20pmSoftware: Friday, February 2, 12:00 – 12:20pm

It should look like this:

Books: Thursday, February 1, 11:00 – 11:20am

Docs: Thursday, February 1, 2:00 – 2:20pm

Software: Friday, February 2, 12:00 – 12:20pm

SanfordWhiteman
Level 10 - Community Moderator

Re: Need to include form selections in confirmation email and change the name of the fields

Sure, add a <br> (and a line break for the text version)

$booleanFriendlies[$field]<br>

Velocity strictly honors all whitespace and strictly prints everything in plain text (unless told otherwise) -- behavior users don't get at first. That means if you have a line break (Unicode 000A), as we do typically hit at the end of lines, that line break ends up in the output, unless we add a ## at the end of the line to comment it out.

Also, Velocity doesn't automatically turn line breaks into HTML <br>, you have to tell it you're in an HTML context (Velocity can be used to pre-process anything, so it's goods that it doesn't force HTML).

Ben_Cooper
Level 2

Re: Need to include form selections in confirmation email and change the name of the fields

It all works now. Thanks for you help Sanford. Do you have any other recommendations besides Apache's documentation for learning Velocity?

SanfordWhiteman
Level 10 - Community Moderator

Re: Need to include form selections in confirmation email and change the name of the fields

Just my posts at

     http://blog.teknkl.com/tag/velocity

and, to some degree, the Oracle Java (6) docs.

I don't think there's anybody else writing on these topics, certainly not currently. The Velocity userbase is broad (covering CMS power users and Java developers all over the world) but quite entrenched & quiet. Marketo has likely done more to bring young/new people into Velocity than anyone else, but there are few resources, and even fewer that are accurate. I even had some bugs in some of my earlier blog posts.   

The good thing is you can do TONS of sophisticated things with VTL (it's unlimited once you burrow into Java methods) so you won't hit a boundary technically speaking, though you may lose your mind, as I do regularly, figuring out the right patterns.

JD_Nelson
Level 10 - Community Advisor

Re: Need to include form selections in confirmation email and change the name of the fields

get on my bandwagon to get Shea Cibulsky​ to give Sanford the stage at Summit University Day for a velocity course