Skip to content

Instantly share code, notes, and snippets.

@dancinllama
Created April 26, 2013 19:59
Show Gist options
  • Save dancinllama/5470054 to your computer and use it in GitHub Desktop.
Save dancinllama/5470054 to your computer and use it in GitHub Desktop.
trigger mytrigger on object(before update){
for(Object current : Trigger.new){
Object olObject = Trigger.oldMap.get(current.Id);
if(olObject.MyField__c != current.MyField__c && otherConditionsGoHere){
//Option1
olObject.MyField__c.addError('Cannot do that, Hal..');
//Option2
current.MyField__c = olObject.MyField__c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment