4

When used in bulk, yes, it could hit the SOQL governor limit. You should use the normal Aggregate-Query-Update pattern. Set<Id> contactIds = new Set<Id>(); // Put contactIds in to Set for(Case record: Trigger.new) { contactIds.add(record.ContactId); } // Use AggregateQuery to find cases with 2+ for same Contact contactIds.retainAll( new Map&...


4

You can't. All normal sObject DML is rolled back if an unhandled exception is thrown. Platform Events will escape only if they're configured to be non-transactional (not configured for "Publish After Commit"). If you need to persist data, you could include it as the payload of a non-transactional Platform Event that is persisted by a Platform Event ...


3

Salesforce was founded in 1999, and by 2000 was branded as the "No Software" CRM solution. For the first eight years or so, there was no code-based alternatives, and it worked well enough for many small-to-medium-sized orgs. Apex was largely made as a stopgap for those large orgs with highly specialized processes, which took many years and ...


1

As per the discussion: KISS ("Keep It Simple, Stupid") and avoid complexity in your code; since async updates are acceptable when there's too much data, always do this processing asynchronously. This avoids later problems when the number of records for which DML is performed changes perhaps due to introduction of flows or other processes in later ...


Only top voted, non community-wiki answers of a minimum length are eligible