How to Exclude Salesforce Formula Fields from Replication
How to Exclude Salesforce Formula Fields from Replication
A single Salesforce formula “poison” field can force you to maintain hundreds of field names just to exclude one column from replication. There is a much simpler approach.
Supported environment
This engineering note applies to Salesforce object replication into SQL Server using SQL-Sales.
One field can stop the entire object
A single unsupported Salesforce formula field can prevent an otherwise healthy object from replicating successfully.
The obvious workaround is to maintain an inclusion list containing every other field while omitting the problematic column.
If an object contains 400 fields and only one is unsuitable for replication, the traditional approach requires a maintained list of the remaining 399.
That approach becomes increasingly fragile as the Salesforce schema evolves. Newly created fields are silently omitted until somebody remembers to update the inclusion list.
Why it happens
Salesforce objects can contain formula fields, calculated values and organisation-specific implementations that are valid inside Salesforce but unsuitable for a particular replication process.
In some cases, a formula field may reference a feature, relationship or data type that causes the query or downstream SQL import to fail.
The object itself is not necessarily broken. The failure may be caused by only one field within an otherwise usable schema.
Explicitly list every field you want
The conventional solution is to replace automatic field discovery with an explicit inclusion list.
Select every valid field individually and omit the one formula field that causes the failure.
This may solve the immediate problem, but it introduces a permanent maintenance dependency. Every future Salesforce field must also be added manually.
The larger and faster-moving the object becomes, the more likely the inclusion list is to drift away from the real Salesforce schema.
Define the exception, not the entire schema
SQL-Sales allows selected fields to be excluded while every other valid Salesforce field remains automatically included.
exec ss_Replica
'Production',
'Account',
'Exclude(BadFormula__c)'
SQL-Sales retrieves the complete Salesforce field list and removes only the fields named inside the Exclude() clause.
Multiple fields can be excluded by separating them with commas:
exec ss_Replica
'Production',
'Account',
'Exclude(BadFormula__c,LegacyValue__c,UnusedField__c)'
The schema remains dynamic
The exclusion list contains only the exceptions. SQL-Sales continues to discover and replicate every other supported field.
This reverses the usual field-selection model. Instead of documenting hundreds of fields that should be replicated, the command records only the small number that should not.
Things to watch for
- Exclude only fields that genuinely cause a query, conversion or downstream processing problem.
- Use the Salesforce API field name, such as BadFormula__c, rather than the field label shown to users.
- Multiple field names must be separated by commas inside the Exclude() clause.
- Review exclusions periodically so temporary workarounds do not become permanent without reason.
Add a short comment to the calling procedure or operational documentation explaining why each field was excluded. The field name alone may not explain the original Salesforce failure six months later.
Maintain the exception—not hundreds of field names
A single problematic formula field should not require a permanently maintained list of every other field in the object.
The SQL-Sales Exclude() syntax removes only the specified exceptions while retaining dynamic discovery of the remaining Salesforce schema, including fields added in the future.