One of our objects has about 50 checkboxes. I've been asked to create a picklist that allows a user to "Check All" or "Uncheck All" of the checkboxes. My first thought was a workflow rule, but creating 100 field updates, and two rules based on the picklist seemed excessive. I assume a trigger would work better, but I'm having issues with the logic.
trigger UpdateAllCheckboxesOnOSR on Issue__c (before insert, before update) {
for (Issue__c issueNew : Trigger.new){
Issue__c issueOld = Trigger.oldMap.get(issueNew.ID);
if(issueOld.Official_Statement_Checklist__c != issueNew.Official_Statement_Checklist__c){
if(issueNew.Official_Statement_Checklist__c == 'Check All'){
issueNew.Principal_Amount_Sources_of_Payment__c = True;
}
if(issueNew.Official_Statement_Checklist__c == 'Uncheck All'){
issueNew.Principal_Amount_Sources_of_Payment__c = False;
}
}
}
}
If I can get this to work, I'll add all of the other fields for update to True or false. But wanted to get feedback from the community if a trigger is the best way to do this? And if so, why is my trigger not firing as I expected.