Skip to content

The AsyncActions Class

GitHub Action edited this page Oct 30, 2026 · 7 revisions

The AsyncActions class serves as the central namespace and entry point for the async actions framework. It provides utility methods for creating async actions and contains essential inner classes and interfaces, which are documented elsewhere in this wiki.

Methods

groupByRecord

Groups a processor's actions by their RelatedRecordId__c, into one AsyncActions.RecordGroup per record, keyed by the record's Id. Processors that act on one record per action can then query every record once, and give all actions for a record the same outcome.

  • Map<Id, AsyncActions.RecordGroup> groupByRecord(AsyncActionProcessor__mdt settings, List<AsyncAction__c> actions, AsyncActions.DuplicateBehavior behavior)
  • Map<Id, AsyncActions.RecordGroup> groupByRecord(AsyncActionProcessor__mdt settings, List<AsyncAction__c> actions)

Actions with a blank RelatedRecordId__c share the group under the null key. An action whose RelatedRecordId__c is text that is not a valid record Id fails right away with SUDDEN_DEATH, since no retry could fix it, and joins no group. The rest of the batch is unaffected.

The two-parameter overload uses GROUP_DUPLICATES. See AsyncActions.DuplicateBehavior for when to fail duplicates instead.

initAction

Creates a new AsyncAction__c record configured with the specified processor settings and context information.

  • AsyncAction__c initAction(AsyncActionProcessor__mdt settings, Id relatedRecordId, String data)
  • AsyncAction__c initAction(AsyncActionProcessor__mdt settings, SObject record, String data)
  • AsyncAction__c initAction(AsyncActionProcessor__mdt settings, Id relatedRecordId)
  • AsyncAction__c initAction(AsyncActionProcessor__mdt settings, SObject record)
  • AsyncAction__c initAction(AsyncActionProcessor__mdt settings)

All overloads initialize the action with "Pending" status, set NextEligibleAt__c to current time for immediate processing, and apply configuration from processor settings.

Inner Types

This class contains several inner types that provide core framework functionality:

Clone this wiki locally