I have a trigger (simplified sample code below) that is using field describes to determine what fields were changed to conditionally update some other field on the same record. The problem is that you are limited to 100 field describes so any mass update will break this trigger.
How can I get around this? Future methods won't work since they can only take primitive parameters and I need to know the values of any potentially changed fields. Enumerating every possible changed field is not feasible.
trigger ObjectBefore on Object__c (before update) {
Set<String> fieldsToIgnore = new Set<String> {'custom_field1__c',
'custom_field2__c',
'custom_field3__c'};
for (Object__c obj : Trigger.new) {
if (Trigger.isUpdate) {
Object__c old = Trigger.oldMap.get(obj.Id);
Map<String, Schema.SObjectField> fieldMap = Schema.SObjectType.Object__c.fields.getMap();
for (String fieldName : fieldMap.keyset()) {
if(!fieldsToIgnore.contains(fieldName.toLowerCase()) && old.get(fieldName) != obj.get(fieldName)) {
obj.Custom_Field4__c = 'some value';
System.Debug('**** Field Changed: ' + fieldName);
}
}
}
}
}