function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShikibuShikibu 

Database.SaveResult won't provide id for failed update operation

I am testing a webservice that accepts a list of Asset Ids, changes each asset.Status to "Active." 

 

When there is any kind of error on the DML update, the saveresult does not provide me with the Id. Here's an example; the asset has been deleted.

 


20100202213448.608:Class.AssetActivateWS.activateAssets: line 35, column 13: Database.SaveResult[getErrors=(Database.Error[getFields=();getMessage=entity is deleted;getStatusCode=System.StatusCode.ENTITY_IS_DELETED;]);getId=null;isSuccess=false;]

 

I can add code to generate the id myself, but it seems strange (a bug even) that SaveResult.getId returns null if saveResult.isSuccess is false.

 

Any insights?