Newer Version Available

This content describes an older version of this product. View Latest

Apex Considerations for Salesforce Connect External Objects

Apex code can access external object data via any Salesforce Connect adapter, but some requirements and limitations apply.
  • These features aren’t available for external objects.
    • Apex-managed sharing
    • Apex triggers (However, you can create triggers on external change data capture events from OData 4.0 connections.)
  • When developers use Apex to manipulate external object records, asynchronous timing and an active background queue minimize potential save conflicts. A specialized set of Apex methods and keywords handles potential timing issues with write execution. Apex also lets you retrieve the results of delete and upsert operations. Use the BackgroundOperation object to monitor job progress for write operations via the API or SOQL.
  • Database.insertAsync() methods can’t be executed in the context of a portal user, even when the portal user is a community member. To add external object records via Apex, use Database.insertImmediate() methods.

When running an iterable batch Apex job against an external data source, the external records are stored in Salesforce while the job is running. The data is removed from storage when the job completes, whether or not the job was successful. No external data is stored during batch Apex jobs that use Database.QueryLocator.

Important

  • If you use batch Apex with Database.QueryLocator to access external objects via an OData adapter for Salesforce Connect: