You can use Salesforce Process Builder to generate encrypted prefill links without Apex triggers and store these links on your Primary object records so they can be sent to users.
1. Navigate to Setup > Process Builder > Click New
2. Enter information for when link generation should be triggered
3. Add Object. Select Object and when to start the process.
4. Setup any criteria (optional).
5. Add Action to execute
- Action Type: Apex
- Apex Class: VisualAntidote__ProcessBuilderGeneratePrefill
- Apex Variable - formRecordId: [Get your form record id from the ‘Edit’ link in-app - i.e. https://visualantidote.na122.visual.force.com/apex/FormEditor?id=a0U3s000004ns99EAA ]
- Apex Variable - prefillFieldAPIName: The API name of the URL field on your Primary object to store the prefill link
- Apex Variable - sfRecordId: [Primary Object API Name].Id
- Apex Variable - hostedURLPrefix: $GlobalConstant.Null OR the URL where form is embedded if not formstack.io.
6. Activate Process
Guest User Records
🔺 In order to make sure that records created by Guest users also contain prefill links, we will need you to copy of sample Apex code into your own org and setup another Process Builder in the exact same way as above. This is because Salesforce does not allow us to package code that uses “Without Sharing” but you can create custom code that does this so that links can be created on records created/modified by Site guest users.
Note that the class name in the sample code is ProcessBuilderGeneratePrefillGuest instead.
🔺 Site guest users and community guest users will also need sharing rules set up to allow them access to a form's prefill settings. You will need to configure sharing settings for the guest user who is creating records. Please follow the instructions in this related article to set up sharing rules for the guest user.