Dynamic Prefill for Salesforce

💡First: See this article for a list of all the methods you can use to update or relate to existing Salesforce data with forms


Dynamic Prefill allows you to prefill your form with data from one or more related Salesforce records. The data is live and up-to-date when the form is refreshed - this is why it is called “dynamic” since we don’t pass prefill data directly in the url. 


When to Use Dynamic Prefill?

If you want an end-user to click a link to go to a form prefilled with live Salesforce data then Dynamic Prefill is the easiest and fastest way to achieve this.


How to Use Dynamic Prefill?

Enable Dynamic Prefill by going to the Publish Options of your form. You can click Publish if you are in the editor. 


You can choose to prefill on an object level. For example, on a form that contains Contact and Account fields, you can choose to prefill both or just the primary object. 


💡If you wish to prefill both objects but want to clear some fields so they can be updated by the user, then you can use our JavaScript API to clear those fields before the form is loaded. 

// For Text, Number, Picklist fields 
function FF_OnAfterRender(){

// For Checkbox, Radio, Star, NPS
function FF_OnAfterRender() {
var picklist = fs('#TestObject__c\\.Test_Picklist__c');

// Note: initFlexControl second variable should be true if the field is read-only
initFlexControl(picklist, false);


How to Generate Prefill Links?

With Dynamic Prefill enabled for your forms, you will need to generate encrypted prefill links to your forms and make them available to your users.

💡The prefill link is the hosted form URL (i.e. formstack.io/ABC12345?{encrypted_value}) or the page where the form is embedded (i.e. happycompany.com/profile_update?{encrypted_value})
The encrypted value in prefill links contains your Salesforce org id, the Primary Object record id and the form id. The Primary Object allows us to find all other related records from which to prefill from.

There are various ways to generate a prefill link that end-users can click on:

  1. Automatic Apex Trigger - Easiest method in-app
  2. Send By Email - Email the link directly to users (in-app)
  3. Export Links - Download a CSV of prefill links in-app
  4. Process Builder Prefill - Trigger prefill link generation in Salesforce Process
  5. Custom Apex Trigger - Code-based solution in Salesforce


Trouble with Prefill Links? 

Keep in mind that prefill links point to a specific org id and form on that org. When refreshing full or partial copy sandboxes, records may contain links to production forms. Your forms will also need to be republished to take on a new identity on sandboxes and for you to create prefill links that point to this sandbox.

Every org is different so please email us if you run into any issues. We created an article to deal with some of the more common issues seen with generating and using prefill links

Was this article helpful?
4 out of 12 found this helpful



Article is closed for comments.