SOLVED

Change email content based on form hidden field

Go to solution
trevlarrr
Level 4

Change email content based on form hidden field

We've created a landing page to download a series of reports and a form in a lightbox that captures the asset ID in a hidden field of the report they clicked on. Once they submit the form I want to send them a confirmation email that will have the report name and URL to download the report. I'm assuming this can be done via tokens but I can't find an answer of how to update the name and URL in the email based on the asset ID from the form (using the ID rather than the URL so it's not contained within the code of the landing page).

 

Is there a way to do this with dynamic email content or is the only way to create a separate email for each report and send the appropriate email via flow choices?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Change email content based on form hidden field

Simple. You set the URL and Title based on the hidden field's value using the velocity script.

 

#set( $allReportDetails = {
  "Hidden Field Value1" : {
    "title":"Report1",
    "url":"www.example.com/report1"
  },
 "Hidden Field Value2" : {
    "title":"Report2",
    "url":"www.example.com/report2"
  }
}
)
#set( $aReport= $allReportDetails[$lead.hiddenField]) 

<p>Report Title:${aReport.title}</p>
<p><a href="https://${aReport.url}" target="_blank">Here's your Report</a></p>

 

Add this in an Email Script token, replace "Hidden Field Value1", "Hidden Field Value2" with actual hidden field values, and update existing and add more records in the keymap if required. And, of course, replace $lead.hiddenField so it reflects the correct name of your hidden field as well. Let us know if you have questions.

 

I'd recommend you to Null the hidden field's value using a Change Data Value flow step after the Send Email flow step, so you don't ever reference the previous form's value in your email.

 

 

View solution in original post

trevlarrr
Level 4

Re: Change email content based on form hidden field

@Darshil_Shah1 - I've just figured out it was missing the { } around the hidden field, it's working now I've added those, thank you!

View solution in original post

6 REPLIES 6
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Change email content based on form hidden field

Simple. You set the URL and Title based on the hidden field's value using the velocity script.

 

#set( $allReportDetails = {
  "Hidden Field Value1" : {
    "title":"Report1",
    "url":"www.example.com/report1"
  },
 "Hidden Field Value2" : {
    "title":"Report2",
    "url":"www.example.com/report2"
  }
}
)
#set( $aReport= $allReportDetails[$lead.hiddenField]) 

<p>Report Title:${aReport.title}</p>
<p><a href="https://${aReport.url}" target="_blank">Here's your Report</a></p>

 

Add this in an Email Script token, replace "Hidden Field Value1", "Hidden Field Value2" with actual hidden field values, and update existing and add more records in the keymap if required. And, of course, replace $lead.hiddenField so it reflects the correct name of your hidden field as well. Let us know if you have questions.

 

I'd recommend you to Null the hidden field's value using a Change Data Value flow step after the Send Email flow step, so you don't ever reference the previous form's value in your email.

 

 

trevlarrr
Level 4

Re: Change email content based on form hidden field

Thanks @Darshil_Shah1, just to confirm I put the relevant asset ID after the colon in 

 "Hidden Field Value1" : {

Are there any other fields I need to change to our fields or is it just the $lead.hiddenField ?

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Change email content based on form hidden field

You should replace the Hidden Field Value1/Hidden Field Value2 with the actual values you pass to the hidden field for each of the available reports. The title and url parameters also need to be updated with the corresponding values for each hidden field value. The $lead.hiddenField is referencing the actual hidden field that you have placed on your report download form. If you're facing issues, share the code you're using, and we can help troubleshoot it. Thanks!

 

trevlarrr
Level 4

Re: Change email content based on form hidden field

Hi @Darshil_Shah1 I think I must be doing something wrong here, this is the code I'm using (changed domain and munchkin ID just for here)

 

#set( $allReportDetails = {
  "3241139" : {
    "title":"Argentina's Drought Poses Economic Problems",
    "url":"https://go.domain.com/rs/000-XXX-000/images/axco_global_risk_analysis_argentina_202304.pdf"
  },
 "3049355" : {
    "title":"The World Ahead 2023",
    "url":"https://go.domain.com/rs/000-XXX-000/images/the_world_ahead_2023.pdf"
  }
}
)
#set( $aReport= $allReportDetails[$lead.axcoLastReportID]) 

<p>Report Title:${aReport.title}</p>
<p><a href="https://${aReport.url}" target="_blank">Here's your Report</a></p>

 

 

 

But in the email it's not pulling the title and URL, it just has the code:

trevlarrr_0-1684410575983.png

 

trevlarrr
Level 4

Re: Change email content based on form hidden field

@Darshil_Shah1 - I've just figured out it was missing the { } around the hidden field, it's working now I've added those, thank you!

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

Re: Change email content based on form hidden field

Cool! You're welcome.