Populate (or Prefill) a Form with Salesforce Data 


In this Article
Related Articles

You can populate a form using custom links or buttons created in Salesforce. These links can be added to the Salesforce interface and also included in emails sent from your Salesforce account.

Before you begin, be sure that you have created the necessary fields that you wish to prefill on your form. You can see which fields exist on your form, and their prefill names, in Prefill Through the URL.


Use a Prefilled Link in a Salesforce Email Template

  1. Login to your Salesforce application and open your Email Templates in the App Launcher.
  2. Click New Template.
  3. Provide your template with a unique name, such as "Contact Happiness Survey."
  4. Create the body of your email template.
  5. At the point where you wish to create your prefilled FormAssembly form link, type:
    <a href="">Please click here to take our survey.</a>
  6. Paste the link to your form into the href attribute, resulting in:
    <a href="https://www.tfaforms.com/FORM_ID">Please click here to take our survey.</a>
  7. Add to the link "?tfa_XXX=" with tfa_XXX being replaced with either a field alias or your unsafe query parameter.
    <a href="https://www.tfaforms.com/FORM_ID?tfa_XXX=">Please click here to take our survey.</a>
    Refer to the documentation to find the exact syntax for each field.
  8. In the lower right corner of the email body, click to "Insert merge field".

  9. Select the field which you would like to prefill and click "Insert" to add it to the end of the prefilled link.

    <a href="https://www.tfaforms.com/FORM_ID?tfa_XXX={{{Recipient.Email}}}">Please click here to take our survey.</a>
  10. Save the template.
  11. Use this template when sending your campaign to your users.

Salesforce will automatically populate each email with the appropriate data. For example:

<a href="https://www.tfaforms.com/FORM_ID?tfa_Company=Smith Co&tfa_LeadId=a0370000006d7yAAAQ">Please click here to take our survey.</a>

Salesforce does have some limitations when it comes to mail merging. Please see here for more details.


  1. Login to your Salesforce application and click Setup (in the top right corner).
  2. Open the Object Manager.
  3. On any object, click Buttons, Links, and Actions and add a New Buttons or Link. You will choose the object where you'd like your custom button or link to appear in the page layout. 
  4. Enter a label such as "Log a Call" and choose your Display Type and Behavior. Leave the Content Source as "URL". 
  5. Paste the link to your form. For instance:
    https://www.tfaforms.com/FORM_ID
  6. Add to the link "?tfa_XXX=" with tfa_XXX being replaced with either a field alias or your unsafe query parameter.
    https://www.tfaforms.com/FORM_ID?tfa_XXX=
    Refer to the documentation to find the exact syntax for each field. 
  7. Use the "Select Field Type" and "Insert Field" options to add in your mail merge fields:
  8. Your final link should look something like this:
    https://www.tfaforms.com/FORM_ID?tfa_XXX={!Account.Id}
  9. Add the link or button to a page layout (refer to the Salesforce documentation if you need help with this).

That's it! When clicking on the link or button from your Salesforce account, the form should open up with the data pre-populated.


Prefilling a Salesforce Checkbox

Checkboxes require a special method of prefilling. Checkboxes prefill simply by having their ID display in the query string. For example:

https://www.tfaforms.com/FORM_ID?tfa_4&tfa_6

This link will prefill both checkboxes that have the IDs tfa_4 and tfa_6 (assuming that they are checkboxes). This being the case, you will have to use a special formula to prefill them in the URL of a Salesforce email template.

Here is an example of the type of formula that you could use:

https://www.tfaforms.com/FORM_ID?{!IF(Contact.CheckBox_Field__c=True,"tfa_4","")}

This will only show the ID tfa_4 in the event that there is a value for the Contact field labeled CheckBox_Field__c.


Terms of Service · Privacy Policy