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
DoomosthenesDoomosthenes 

Trigger that will only work when using mass upload?

Is there a way for a trigger to tell if edits to records are from a mass upload/edit?

 

I have a trigger that recalculates lat/long fields when the address of an account is changed, but I know the trigger will give me problems when I try to upload or edit accounts en masse because of the 10 query limit.

 

So I need to figure out how to create a trigger that will update the fields when users change the addresses one at a time, but still allow a mass update or edit to do the same without triggering errors.

 

I'm wondering if someone out there with more experience has tried to do something like this before, or have any ideas?

Saikishore Reddy AengareddySaikishore Reddy Aengareddy

In your trigger use something like Trigger.new.size()

 

if(Trigger.new.size()==1){

//do your logic for single record updates/edits/inserts

}else{

//Mass update/insert/edit

}

SaraagSaraag

or you can always use a dedicated username for mass data tasks. And in the trigger you can exclude that user.