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
kryan0618kryan0618 

Update whole object after creation of a new trigger

Hi,

 

I have just created a new trigger to change a field in the Lead object using an AfterInsertUpdate. However, I would now like to update the whole object so all records have a value. How do I go about doing this?

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Rahul_sgRahul_sg
All records will not be updated automatically. You need to update those records in order to populate the information in that field.
You have two options:-
1) Export all the records & run update job using data loader. No need to export all the columns just export Id and any other text/non required field.
2) If no. of records are less then run the following query in your console :
List<Lead> myList = [select id, column1 from lead ]; //this will fetch all records
Update myList;

All Answers

Rahul_sgRahul_sg
All records will not be updated automatically. You need to update those records in order to populate the information in that field.
You have two options:-
1) Export all the records & run update job using data loader. No need to export all the columns just export Id and any other text/non required field.
2) If no. of records are less then run the following query in your console :
List<Lead> myList = [select id, column1 from lead ]; //this will fetch all records
Update myList;
This was selected as the best answer
kryan0618kryan0618

Thanks for the suggestions! Updating as I write this!