đź’ˇ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.Â
Choose to prefill on an object level. For example, on a form that contains Contact and Account fields, you can decide to prefill both or only the primary object.Â
đź’ˇIf you wish to prefill both objects but want to clear some fields so the user can update them, then you can use our JavaScript API to clear those fields before the form is loaded.Â
// For Text, Number, Picklist fieldsÂ
function FF_OnAfterRender(){
  document.getElementById('FIELD_ID_HERE').value = '';
}
// For Checkbox, Radio, Star, NPS
function FF_OnAfterRender() {
var picklist = fs('#TestObject__c\\.Test_Picklist__c');
picklist.val('');
// 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:
- Automatic Apex Trigger - Easiest method in-app
- Send By Email - Email the link directly to users (in-app)
- Export Links - Download a CSV of prefill links in-app
- Generate Forms for Salesforce Prefill URLs using Flow
- Custom Apex Trigger - Code-based solution in Salesforce
Â
Considerations for Prefill Links
Prefill links point to a specific org id and form on that org. Records may contain links to production forms when refreshing full or partial-copy sandboxes. 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. Review here for a robust auto-generating prefill links troubleshooting overview.Â