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
mshroyermshroyer 

Mass update accounts in order to make a Trigger run

Fairly new to apex fyi,

 

I created a trigger that creates multiple records on a custom object based on certain criteria at the account level. So if certain fields on the account have specific values it could create 3-5 different records on the custom object. The trigger runs fine, what I need to do is make it execute on many of our current accounts. We can't wait until each one is manually updated to make the trigger run but since triggers won't run until the record is updated I believe we need to do a mass update on Accounts.

 

If this is correct, what is the best way to mass update accounts in order to make my trigger execute and create the custom records? Is there a way to make the trigger run without doing a mass update? (roughly 5500 accounts would be affected by the trigger)

 

Thank you!

Jia HuJia Hu
1. Export a account list by Dataloader.
2. Revise the .csv list based on your condition to fire the trigger,
3. Then use Dataloader to update the account object, then you will see how the trigger works.
*werewolf**werewolf*

Or:

 

- Take the code in the trigger and refactor it so it's in a class instead (and make the trigger instantiate the class and call the method in it)

- Make a batch Apex method that calls this method in this class for every account

- Run that batch Apex once

- Profit!

mshroyermshroyer

Thanks for the replies! One of our developers here at my company had actually run into this same problem before and was able to help me out with this. We used one of his older programs that he wrote in Python that would connect to salesforce using the "Beatbox" function and pull down all the accounts, update them, then reinsert them into Salesforce in batches of 10. Hardly any extra work on our part, just had to write the query to pull the right accounts and tell it which field to update.