Advanced 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

 

🔺Advanced Prefill is not currently available on NativeCloud plans.

Advanced Prefill allows you to personalize forms that live behind an authenticated portal. It is a feature that allows you to search for a specific record in Salesforce to use as the source for prefill. It is programmatic and allows searching Salesforce using complex criteria that can be determined at runtime. 

 

When to use Advanced Prefill?

Since advanced prefill relies on search criteria instead of a specific encrypted record id, it offers more flexibility. Here are some scenarios for when you should use Advanced Prefill.

  1. You have search criteria instead of a dynamic prefill link that you want to send to people over email. The search criteria can be a combination of data like first_name, last_name, school, program_id, etc..
  2. You want to put a form on a portal that requires authentication and want to use the user profile/session information or other information within the portal page to find a Salesforce record to prefill the form.  
  3. You know the specific id of the record you want to update. We recommend using auto-generated Dynamic Prefill links for these use cases but it is possible to centralize and use Advanced Prefill for these as well.


How to Use Advanced Prefill? 

🔺Advanced Prefill relies on server-side code to encrypt search criteria. We provide sample code for encryption but it requires that you have a server that will run this code to encrypt/decrypt these links.

We recommend you implement this in coordination with your website administrator. 

 

Step 1: Decide on search criteria
The most important step in prefilling a form is to find a record in Salesforce that will drive prefill for your form. The record we look for has to be the same object type as your Primary object on your form. 

Using your search criteria we will find the Primary Object record on your form that you would like to prefill. We only need to find your Primary Object record and we can use that to automatically prefill related record data on your form.  

Once you've determined which fields uniquely identify your user, you'll simply need to put together a query string as follows:

 

fieldname1='fieldvalue1'&fieldname2='fieldvalue2'

 

For example, if I'd like to prefill my contact form with a Salesforce contact by providing a first and last name, I would do the following:

 

FirstName='John'&LastName='Smith'

 

You'll want to use what Salesforce refers to as the 'API Name' of your field, which you can find in your object's field definitions within Salesforce setup or in the Form editor in field settings. For custom fields, you'll normally see a '__c' appended to the end. For example, a custom field named Middle Name would likely have the API name 'Middle_Name__c'.

 

1_api_name.png

 

You can use a combination of any of your primary object's fields to determine the record to prefill. In fact, if you know the Salesforce record ID of the record to prefill, you can provide that using id='xxxxxxxxxxxxxxx'.



Step 2: Enable Dynamic Prefill

To use Advanced Prefill, first enable Dynamic Prefill in Publish Settings and select the objects on your form you would like to prefill.  

 

2_enable_ap.png

 

Step 3: Encrypt your Advanced Prefill query string

 

💡Why is search criteria in Advanced Prefill links encrypted?
We encrypt search criteria data using a key specific to your org so that no one can create random links that pull data out of your Salesforce org without your permission. This means that you remain in complete control of which data is accessible externally to Salesforce. 

 

Once you've put together your query string, you will need to encrypt the information so that malicious or unauthorized users cannot prefill your form with other users' Salesforce records. To do so, we provide a unique secret key that you can use to encrypt your query string. 

 

3_key_code.png

 

🔺We use RSA encryption to ensure your query string cannot be tampered with. It is important that you keep this key secure as anyone with access to this key can retrieve your Salesforce information.

We provide sample code to use to encrypt your query string in a number of programming languages. The specific code is unique to the web hosting solution you are using. 

 

💡 We have noticed that some customers use a Microsoft-based hosting system that does not have compatible RSA encryption libraries. We have provided sample code that works on Microsoft based systems if the sample code in-app does not function. See our git repository and the following Microsoft reference article.

Step 4: Update your form links 

Once you've implemented your encryption solution and have an encrypted string available for use, you can then take the resulting encrypted string and pass it into your form's page URL. 

 

For example, if your form is embedded on http://ilovecats.com/profile then your new prefill link will be:

 

http://ilovecats.com/profile?dp={your_encrypted_string}

 

You can alternatively append your encrypted string into your form's embed code directly as follows:

 

<script type="text/javascript" id="jsFastForms" src="https://sfapi.formstack.io/FormEngine/Scripts/Main.js?d=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&dp={your_encrypted_string}"></script>

 

💡In most cases, you will not be generating these encrypted prefill links ahead of time. Rather you will change the links on your website that point to pages hosting your form. The encrypted query string will be generated dynamically and appended to the link behind the scenes in your web site backend code.  



A few things to note

If all goes well, your backend code will read and decrypt your encrypted string, find the record matching the query, and populate your form with that record. 

 

💡If we find more than one record that matches the query you've provided, it will only return the most recently updated record.

🔺If you do not find any records or do not see prefill working then go back to testing with a basic contact form and use the Contact ID as the only query criteria to make sure you have the Advanced Prefill encryption./decryption mechanism working correctly first before attempting to use on more complex forms or data structures. 

 

🔺Sandboxes
When refreshing a sandbox or using a sandbox with the app pre-installed because it was installed on production, we recommend the following steps before using Advanced Prefill:

  1. Republish your form
  2. Verify regular submissions are working and going to the correct org with the new form link.
  3. Update your test website to use the new form link or embed code from your sandbox (not production org)
  4. Test using Auto-Generated or Exported Dynamic Prefill URL
  5. Refresh your Advanced Prefill key (It will be production without refresh)
  6. Test using a simple Contact form with Contact ID (new sandbox record) as query criteria. 

 

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

Comments

0 comments

Article is closed for comments.