I need help with updating existing bulk records just for the sake of firing a trigger.

Below is my situation:

We have more than 1 million contacts in our org. Recently we installed a managed package. Two objects in this managed package are used as related lists on Contact. I created a new trigger which on contact insert, it inserts a record in the related list object. This trigger is also fired on after update. The trigger is working for newly created contacts but for the existing old records, we have to click on edit and then hit save to fire the trigger. Is there a way to create an update scenario on all these bulk contact records to fire the trigger so that it populates/updates the related list object?

3 Answers 3


You can use the Apex Data Loader (you'll find it in Setup) to export all your records, then run that CSV file back through the Apex Data Loader for an update. This is probably the easiest solution, but it does require installing some software.

The alternative would be to write a batch class, but that requires a deployment to production. The batch class would look like this:

public class UpdateContacts implements Database.Batchable<sObject> {
  public Database.QueryLocator start(Database.BatchableContext context) {
    return Database.getQueryLocator([SELECT Id FROM Contact]);
  public void execute(Database.BatchableContext context, Contact[] scope) {
    update scope;
  public void finish(Database.BatchableContext context) {

And the associated unit test would just be:

@isTest class UpdateContactTest {
  @isTest static void test() {
    insert new Contact(LastName='Test');
    Database.executeBatch(new UpdateContacts());
    // Note: add a System.assert here to verify trigger ran.

Finally, after deployment, you would just use the Developer Console to kick off an Execute Anonymous script:

Database.executeBatch(new UpdateContacts());

Just create a batch class that queries all the contacts and use an update dml on them. Doesn't sound like it is checking for changed field values so your execute class would look like this:

public static void execute(database.batchableContext bc, List<Contact> cons){
    update cons;
  • @sfdcfox and SFDC Noob, Thank you for the response. I will try that out.
    – Saha
    Commented Jul 20, 2018 at 0:20

New solution based on same idea as SFDC Noob.

Download Salesforce Inspector plug-in. Perform and Update operation, but only give the list of record Ids you want to trigger update for.

I just did this for a list of Closed Won opps, worked like a charm and didn't change the Close Date either. My workflow kicked off and did a recalc of the values I needed to reset.

Awesome and super fast as no new coding needed on my side.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .