Skip to content

Instantly share code, notes, and snippets.

@escgeek
Created August 15, 2018 15:01
Show Gist options
  • Save escgeek/dbece81a90078aa4e581ba649d5e1a82 to your computer and use it in GitHub Desktop.
Save escgeek/dbece81a90078aa4e581ba649d5e1a82 to your computer and use it in GitHub Desktop.
Quick Trigger to update a Picklist
trigger master_Latam_Sales_Transactions on Latam_Sales_Transactions__c (before insert, before update) {
// Lines 7-11 are just FYI debug in case there are recursive issues but otherwise are
// not needed and can be deleted.
if(
(Trigger.isUpdate || Trigger.isInsert) &&
Trigger.isBefore
){
String triggerType = 'Update';
if(Trigger.isInsert){
triggerType = 'Insert';
}
System.debug('[1] ' + triggerType + ' - BEFORE trigger -------');
for(Latam_Sales_Transactions__c lst : trigger.new){
if(lst.Product_Family1__c <> lst.Product_Family_Map__c)
lst.Product_Family1__c = lst.Product_Family_Map__c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment