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

An API call is an inbound request, an API callout is an outbound request. API calls are rate-limited, limiting clients to the number of calls they are allowed to make daily. One API call costs one API call towards this limit. That means that updating 200 records costs the same as updating 1 record, if you place them in the same payload. It doesn't matter if ...


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 ...


1

If you have the flexibility to mark the records that require processing in some way you can then indirectly use a scheduled batch to deal with the end results of the over-all transaction/session. We do this by having two Datetime "timestamp" fields, LastProcessed__c and LastUpdated__c and a Checkbox formula field NeedsProcessing__c set as NOT(...


1

What I sometimes do is use a platform event to get out of the context and then I can avoid a queueable altogether. I define the platform event (normally just with a payload var that is a serialized map with all the params. Then, fire the event and in the event handler, unpack the event which has these params: className callableMethodName callableParams Here ...


1

We have found that COUNT queries can still face limits in the form of exceeding CPU limits in the transaction, and I believe this is actually caused when the WHERE clause for the SOQL query requires significant filter-related processing against unindexed columns. This help page discusses "selectivity": For best performance, SOQL queries must be ...


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