1

How do I mass update existing records with a field where the value is blank? I need code to be executed in the Execute Anonymous window.

Field name is Owner__c Object name is Account__c

I am using the below query to pull the data. Now I need to overwrite the blank fields in the records.

SELECT Id, Name, Owner__c, Originator__c FROM Account__c WHERE Owner__c = ''
3

You can use following code

List<Account> listAccount = [
    SELECT Id, Name, Owner__c, Originator__c
    FROM Account__c WHERE Owner__c = ''
    LIMIT 10000
];

for(Account__c acc : listAccount)
{
  acc. Owner__c = 'YOUR NEW VALUE'
}

update listAccount;
  • great... select the answer and close this question. – Himanshu Dec 16 '15 at 18:44
  • what if there are more than 50000 records? – Mubeen Qawi Feb 3 '16 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.