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
Aiden ByrneAiden Byrne 

Records that cannot be updated by an Administrator

I know that a lead with the isConverted flag set to true cannot be updated, even by an administrator. 

 

Does anyone know if there are any other conditions where Leads, Accounts or Opportunities cannot be updated (apart from transient locks)?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
forecast_is_cloudyforecast_is_cloudy

Do mean are there cases where Sys Admins can't update Leads, Accounts or Opportunities? Or a general user? If former, then no I don't believe there is any other case where a Sys Admin can't update a record. If latter, there can many cases where a general user can't update a L/O/A. For e.g. record may be locked for approval. The user may not have edit privileges to the record. etc. 

All Answers

forecast_is_cloudyforecast_is_cloudy

Do mean are there cases where Sys Admins can't update Leads, Accounts or Opportunities? Or a general user? If former, then no I don't believe there is any other case where a Sys Admin can't update a record. If latter, there can many cases where a general user can't update a L/O/A. For e.g. record may be locked for approval. The user may not have edit privileges to the record. etc. 

This was selected as the best answer
Aiden ByrneAiden Byrne

Thanks. 

 

I'm asking about the Administrator case only. Context on my question; I have an APEX job that wakes up and does some processing on standard records. Obviously, this should always ignore converted leads as these can never be updated. I wanted to double check that there were no other similar cases.

sfdcfoxsfdcfox

I recommend that you use the AllOrNone argument on the Database methods (i.e. Database.update). You can then silently ignore records that would fail, and process the rest. Using a stateful class, you could identify which records failed, or at least a count of failed records. Any record can fail because of a concurrent record lock (use "select ... for update" to avoid this scenario). Remember, updates can also fail because of validation rules, Apex Trigger errors, etc. I'd have to think about all the reasons why it could fail, but that list, if it were exhaustive, would likely encompass very unusual and one-off scenarios. Just use the AllOrNone argument, and it will silently ignore any failures; since you're using Batch Apex, the worst case scenario is that none of the records are updated in a batch of 200 (this is unlikely, but can occur because of the three-strike rule).

Aiden ByrneAiden Byrne

Thanks sfdcfox. I'm using the AllOrNone argument for the reasons you outline.