+ Start a Discussion
Wim van BeekWim van Beek 

Callback result in Database.insertAsync with external object

When inserting an external object, it must be done with Database.insertAsync and a callback function. In this callback function there is a Database.SaveResult.getId() to indicate the reference to the record just created and stored in SFDC.

Would need a referencefield as part of the insertAsync method() to return this value again as part of Database.SaveResult.

Anyone a clue how to do this? The returned id in the callback cannot lead me back to the original inserted rows.

So to user Database.insertAsync , you define insertAsync(sobject, callback)

and "processSave" method of ​callback class is called after the remote operation is completed.

So i belive you have a issues that Database.SaveResult.getId() is not returning you the salesforce 18 digit Id ??

what is  it returnig exactly ??
Wim van BeekWim van Beek
The use case is to copy a task to an external object. When arrived external, it must reset the CopyToExternalBit__c on Task

The callback will give me the 18 digits id of the external object. That works fine. If I need to get the reference to any other object (Task in this case)  I need to get this external object again.

In this external object however, I do not have the a reference to the source of (in this case) Task.This external object cannot be extended with an extra field. It also requires another external call. An solution would be to pass some parameter (eg. id field) with this insertAsync call.