🔺 Auto-generating dynamic prefill links using an Apex Class trigger requires the "Author Apex" user permission which is not available in all editions of Salesforce. If available in your edition, it must be granted to the Primary Formstack app user using the profile or permission set. See this article to verify which Salesforce editions support it and how to enable it.
You can create a link for every record of your Primary object and store this on the URL field. This link can be used by any other app, process or the API to do things like send emails or SMS.
In Publishing Options, with Dynamic Prefill enabled, Click the “Auto-generate prefill links” toggle and select the URL field that will store the generated prefill link.
🔺Note: The prefill link URL field must be on the Primary object. This is because we use the Primary object record to find the other related object records to prefill data from.
By default, prefill links will be for the hosted URL of your form (formstack.io) but you can override this and set links to be your website where the form is embedded.
Setup Apex trigger: The last step is to click”Apply for New Records”. This will create an Apex trigger that is fired for every Primary object record that is created. This means that only new records will have the prefill link.
To set the prefill link for previously created records, select the List View for which to apply the link to and click “Update Existing Records”. The success notification indicates the request was processed successfully however this is an asynchronous operation and it will take a few minutes to complete. If you run into issues, consider changing the List View to contain fewer records or use the Force.com data loader tool alongside the Export Links feature described below.
🔺 In some cases, the prefill link generation will fail because of contention with other processes in your org. We can decrease the batch size so this is less likely to happen. Please contact email@example.com to do this if you run into issues where the link is not configured on new records.
Alternatives to Automatic Apex Trigger
Some orgs encounter a lot of issues with Apex triggers and if this is the case then other methods like using Process Builder or a custom Apex trigger are good alternatives.
We recommend starting with Automatic Apex Trigger, then trying Process Builder and only then trying a custom Apex trigger.
🔺Advanced: If you would like to use Apex prefill triggers but are seeing issues enabling the trigger, this could be because validation rules on your object are preventing us from automatically creating the Apex trigger. In this case, you can use a custom Apex trigger that takes validation rules or the specific needs of your object into account in the Apex trigger’s unit test.
Also, Apex prefill triggers are not compatible with objects that have more than one level of required lookup fields. For example, if your primary object has a required lookup field to another object, if that other object also has a required lookup field, you will not be able to enable the feature because we cannot create the Apex trigger automatically but this can be overcome with a custom trigger that you create.
See this article for guidance in setting up a process in Salesforce to create encrypted prefill links.