alix-o
5/31/2013 - 3:42 PM

Check if field value is contained in a defined set, and update the field.

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;
}