I'm working with a script that pulls checkbox responses from a form field to a response email through an email script token. Script is as follows:
#set( $singleInterests = $lead.documentsDigital.split(";") )
#if( $singleInterests.size() )
#foreach( $singleInterest in $singleInterests )
## ${singleInterest}
<a href="https://info.gepower.com/rs/232-DKG-508/images/${singleInterest}">${singleInterest}</a><br>
#end
#end
I have 4 other fields and created another script for each in the same token that is structured just like the one above, but with the field name changed. I'm getting some weird behavior...when I test, the response email contains links to documents that I did not check. I tried putting all 5 fields into one script, but I don't think I have the syntax right.
Here's what I tried:
#set( $singleInterests = $lead.documentsDigital.split + $lead.documentsServiceAgreements.split + $lead.documentsUpgrades.split + $lead.documentsServiceCenter.split + $lead.documentsGenerator.split (";"))
Any suggestions would be greatly appreciated!
I tried putting all 5 fields into one script, but I don't think I have the syntax right.
Mmm no, you don't.
#set( $singleInterests = $lead.documentsDigital.split + $lead.documentsServiceAgreements.split + $lead.documentsUpgrades.split + $lead.documentsServiceCenter.split + $lead.documentsGenerator.split (";"))
This is adding functions together. Without getting too far into it, let's say that's definitely not what you want.
If you have multiple multiple-interest fields:
#set( $lead.allMultipleInterestFields = [
$lead.documentsDigital,
$lead.documentsServiceAgreements,
$lead.documentsUpgrades
] )
#set( $singleInterests = $display.list($lead.allMultipleInterestFields,";").split(";") )
#if( $singleInterests.size() )
You have the following interests:
#foreach( $singleInterest in $singleInterests )
${singleInterest}
#end
#end
OK, that's very helpful, thank you. I tried putting that in my token and made sure all of the fields are checked on the right, saved. But when I tried to approve my response email, I got this error:
Validation Error approving WC-2017-03-PS-WTUI-Conference.Email-V2 —
An error occurred when procesing the email Body!
Encountered "]" near
$lead.documentsServiceCenter,
$lead.documentsGenerator,
] )
#set( $singleInterests = $display.list($lead.allMultipleInterestFields,";").split(";") )
#if( $singleInterests.size() )
Do you know why it's not liking the bracket?
Can you post your token here (not just the error)? And please try to use the syntax formatting/highlighting feature. It's really hard to to read code that isn't in a monospace font and set off from text.
Here you go, thank you for showing me that. I figured out what was causing that error...a "comma" after Generator. I'm getting closer. Now my only problem is that I'm still getting responses that I didn't pick. It could be my testing methodology. I give myself a new First Name and Last Name each time I fill out the form, and I'm removing myself from the program before I submit. I'm still getting document links in my response email that I didn't check off on the form. Do you know what could be causing that to happen?
#set( $lead.allMultipleInterestFields = [
$lead.documentsDigital,
$lead.documentsServiceAgreements,
$lead.documentsUpgrades,
$lead.documentsServiceCenter,
$lead.documentsGenerator
] )
#set( $singleInterests = $display.list($lead.allMultipleInterestFields,";").split(";") )
#if( $singleInterests.size() )
You have the following interests:<br>
#foreach( $singleInterest in $singleInterests )
##${singleInterest}
<a href="https://info.gepower.com/rs/232-DKG-508/images/${singleInterest}" style="color:#005eb8;">${singleInterest}</a><br>
#end
#end
Changing your First and Last Name will still merge with the same record in Marketo (deduped by email address).
Hence you'll get any documents that were ever requested by that lead, since you're not blanking out previously filled-in values.