SOLVED

Checkboxes in Alert Emails

Go to solution
Ashley_Bland
Level 2

Checkboxes in Alert Emails

Hello Marketo friends, I'm hoping someone out there can help me with an issue I've run into with a web form using checkboxes with boolean fields.

I want to make sure that the email alert I send based on the form being filled out only sends the fields that are checked at the time of the form fill, not historical requests.

 

Scenario:

In testing out my form initially, I selected checkbox "a" and hit submit. Email alert shows that I selected checkbox "a."

In the second form fill-out, I selected checkbox "b" and hit submit. Email alert shows I have selected both checkbox "a" and checkbox "b."

 

Any insight would be helpful! Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes in Alert Emails

For bullets 3 and 4, are there any articles you could point me to? (VERY new to both JS and Velocity)

For the JS portion, here are 2 demos, each using a different format to store the form data in the Textarea:

For reasons too complex to get into here, the second one (Form/URL variant) is, perhaps surprisingly (or not!) given the age of the URL-encoded format, better for processing in Velocity. I'll be doing a blog post on that soon, since it relates to relatively recent discoveries.


The Velocity portion: well, there's gonna be a lot to learn. Essentially you end up with 2 Maps (you can think of these as like basic JS {} Objects... though actually they're 100x more like JavaScript Maps, which fewer people are familiar with). Each Map represents a form post. You want to get the delta (difference) between the two. You can do this with a #foreach loop or if you want to get fancy, with the Set.removeAll method.

As you can read, it's prrrrrrobably not for someone who is very new to these 2 languages, maybe if you were steeped in one but not the other though.

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes in Alert Emails

Can be done, but it's not straightforward.

Marketo doesn't automatically expose the contents of an individual form submission (except in the Activity Log detail, which can't be used in emails), let alone the diff between that form submission and the previous one.

Here's what you can do:

  • Set up 3 Textarea fields: LastFormData, HistoricalFormDataN, and HistoricalFormDataNMinus1.
  • Set up a trigger SC on Data Value Changes to the field LastFormData. The flow: set HistoricalFormDataNMinus1 to {{lead.HistoricalFormDataN}}, then setHistoricalFormDataN to {{lead.LastFormData}}.
  • Add JS to your forms that, on submit, populates LastFormData (a hidden field) with all of the current fields for that submission, as either a JSON-like string or query-like URL-encoded string, together with the current timestamp.
  • In Velocity, convert $lead.HistoricalFormDataN and $lead.HistoricalFormDataNMinus1 to objects. Compare their properties. The objects represent the newest and second-newest form posts, so any properties that are different in $lead.HistoricalFormDataN are by implication the latest-set values.

Note this will only work for data values changed via successive Filled Out Forms. Other ways of changing data, like flows, API calls, or CRM sync, won't be captured. It's firmly on the "partial solution" side, but would allow you to deal with the exact situation you describe, where checkbox A was already checked, so you don't want to imply that they just checked it.

Ashley_Bland
Level 2

Re: Checkboxes in Alert Emails

Thank you so much, Sanford! I knew you'd have an answer!

For bullets 3 and 4, are there any articles you could point me to? (VERY new to both JS and Velocity)

SanfordWhiteman
Level 10 - Community Moderator

Re: Checkboxes in Alert Emails

For bullets 3 and 4, are there any articles you could point me to? (VERY new to both JS and Velocity)

For the JS portion, here are 2 demos, each using a different format to store the form data in the Textarea:

For reasons too complex to get into here, the second one (Form/URL variant) is, perhaps surprisingly (or not!) given the age of the URL-encoded format, better for processing in Velocity. I'll be doing a blog post on that soon, since it relates to relatively recent discoveries.


The Velocity portion: well, there's gonna be a lot to learn. Essentially you end up with 2 Maps (you can think of these as like basic JS {} Objects... though actually they're 100x more like JavaScript Maps, which fewer people are familiar with). Each Map represents a form post. You want to get the delta (difference) between the two. You can do this with a #foreach loop or if you want to get fancy, with the Set.removeAll method.

As you can read, it's prrrrrrobably not for someone who is very new to these 2 languages, maybe if you were steeped in one but not the other though.

Ashley_Bland
Level 2

Re: Checkboxes in Alert Emails

Thank you, Sanford, for your help! Believe me when I say I wish I had your skills! Based on your last answer, I believe you are correct that this is something I will have to work with someone else more fluent from my organization on this type of scenario!