One of the more powerful features of Formstack for Salesforce is the 'Upsert' feature. This allows you to define one or more fields in your form as 'Upsert' fields - that is, fields that decide whether we update an existing Salesforce record upon form submission or we create a new one. To mark a field as an Upsert field, simply check the box labeled 'Update existing Salesforce record matching this field value' in the field's settings area.
For fields that have this option enabled, Formstack will check your Salesforce instance upon form submission for existing records that match the value provided in all of those fields. If a match is found, Formstack will update the record with the information submitted in the form. Otherwise, Formstack will create a new record.
There are a number of important factors to consider when deciding to use Upsert functionality for your forms:
- Formstack will only update existing records if exactly one (1) match is found. If no matching records are found, Formstack will create a new record. However, if multiple matching records are found, the form submission will fail, and no records will be created or updated.
- In situations where you check 'Update existing Salesforce record matching this field value' for more than one field for an object, all of the fields will be considered when looking for an existing record. For example, if you check 'Update existing Salesforce record matching this field value' for First Name and Last Name, only records that match both the first name and last name of the form submission will be updated.
- Each of your form's primary and related objects have their own upsert fields. For each object, only the fields marked as upsert fields for that object will be considered when looking for a matching existing record.
Duplicate and Matchings Rules
Salesforce Duplicate and Matching Rules are designed for real-time duplicate matching. Meaning someone has to be logged into Salesforce and manually creating records for them to see the warning message.
These rules have not been designed to play nice with any apps using the API. When we submit information from a Formstack form we are sending information through the API. At that moment no one is physically available to see the error message that is being thrown by these Salesforce duplicate rules and so they just block the submission and cause a failure. It is not uncommon for any organization using 3rd party apps to either deactivate these default rules and set up the duplicate matching criteria within the 3rd party app or create a custom matching rule.
With custom matching rules you get to decide what fields are used to make the match, similar to what you set up on the form (first name, last name, and email) which is different from what Salesforce has in the Standard matching rule (including things like City/phone/company, etc.) These Standard matching rules don't always apply to every organization.