Newer Version Available
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
- 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.
-
If your code accesses external objects
and is used in batch Apex, use Iterable<sObject> instead of Database.QueryLocator.
1global Iterable<SObject> start(Database.BatchableContext batchableContext){ 2return [SELECT Id, salesOrderId__c, note__c FROM SalesOrder__x ORDER BY Id]; 3} - Database.insertAsync() methods can’t be executed in the context of a portal user, unless the portal user is a member of a Salesforce community. To add external object records via Apex, use Database.insertImmediate() methods.