Skip to content

Instantly share code, notes, and snippets.

@mxalix258
Created May 31, 2013 15:42
Show Gist options
  • Save mxalix258/5685878 to your computer and use it in GitHub Desktop.
Save mxalix258/5685878 to your computer and use it in GitHub Desktop.
Check if field value is contained in a defined set, and update the field.
trigger OnboardingEvacSectionUpdate on On_Off_Boarding__c (before insert, before update){
List <On_Off_Boarding__c> obToUpdate = new List <On_Off_Boarding__c> ();
//New set is defined that contains the values 202, 0-203A, etc
Set <String> s1 = new Set<String>{'202', '0-203A'};
For(On_Off_Boarding__c ob: Trigger.new){
// Checks if Desk_location1__c is in the set s1, and updates the field
if (s1.contains(ob.Desk_location1__c)) {
ob.Evacuation_Section__c = '2N';
}
}
Update obToUpdate;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment