Impact of Salesforce to Salesforce on Validation Rules and Apex Triggers
Feb 4, 2009We've received a number of questions from customers on the impact
of Salesforce to Salesforce on existing or new validation rules and apex
triggers. The reality is when two companies connect their salesforce.com
instances, in most cases each company has its own unique set of validation
criteria and triggers.
Additionally, these criteria might be looking at fields that haven't even been
shared between the connected companies. Today, if a customers accepts a
record from a connection and that record fails to meet validation or trigger
criteria we provide a generic error message stating: 0 records accepted.
It is on our roadmap to provide more useful error messages as well as log these
errors in the Connection Audit so the customer can do something about
it.
There is a way, however, for customers to bypass
validation rules and triggers when either accepting a record from a
connection or receiving an update on a connected record from the
connection. The basic idea here is that we bypass these organization
specific rules when first accepting the record or when a connection updates the
record but these same rules are enforced if an internal user creates a new
record or updates an existing record. This is how most of our customers
have configured their connections. Once you make these changes
- you're organization's rules will be Salesforce to Salesforce aware.
It is good practice to include the tasks below in any S2S roll-out plan or
when creating a validation rule or apex trigger.
Changes to Validation rules: the following should be included
within an 'AND' statement with the rest of the rule
Text version:
IF(OR(ISNEW(), ISNULL(Id)), if(ConnectionReceivedId =null, TRUE, FALSE),NOT(AND(ISCHANGED(ConnectionReceivedId), NOT(ConnectionReceivedId = null)))),
NOT(Contains($User.Alias, "pnet"))
Example of Apex Trigger that is S2S aware: sample below is on Opportunities
(same logic for other objects)
Apex trigger
Apex class
If you have any questions on this topic, email: s2s@salesforce.com




0 Comments