You need to sign in to do that
Don't have an account?
Greg Rohman
Preventing an Insert/Update trigger based on value of a field
Hello.
I'm currently updating my Salesforce data from a mySQL database utilizing a 3rd party integration tool. There are some records, though, that may exist in the mySQL database that I don't want updated in Salesforce. Is there some way to perhaps set a flag in a Salesforce record that would prevent updated information from populating in Salesforce? Perhaps comparing Trigger.Old and Trigger.New and rolling back to the previous values?
Thanks.
-Greg
Yes, that's exactly what you'd do. You'd want something like:
trigger SelectiveImport on Opportunity (before update) {
for (Opportunity new_o : Trigger.new) {
if (new_o.DoNotUpdate__c) {
new_o.Field1__c = Trigger.oldMap.get(new_o.id).Field1__c;
}
}
}
That technique is very useful for 'overriding' required fields. For example, upserting an Opportunity requires a Close Date and StageName. If you don't want to override them during the import, use the above logic to revert the values back to their current value.