You need to sign in to do that
Don't have an account?
Bulk Trigger
Hi,
I need to create a trigger but I have problems to create it in a "bulk" way. This is the requirement:
I have accounts which are related to another one (called the main). I can have up to 15 accounts related to this main one.
When some field of the main account, as the account name or address, are modified, I need to replicate this change to the accounts that are related to this main one. This change doesnt have to be replicated always, just when the related accounts fulfills a condition based on its accountrecordtype
I can do
For [a: in trigger.new]{
Account RelatedAccount=[SELECT id, recordtypeId FROM Account Where RelatedAccountId:=a.Id];
}
But this wouldnt be the bulk way and I would probably get errors.
Any help is appreciated.
Thanks,
Antonio
You are correct in this assumption. Your code would run okay outside of a bulk environment (e.g. a user editing a record), but would fall flat when using an import wizard or the data loader. Instead, you would want to do something like this:
Edit: Small modification to the filter criteria.
All Answers
You are correct in this assumption. Your code would run okay outside of a bulk environment (e.g. a user editing a record), but would fall flat when using an import wizard or the data loader. Instead, you would want to do something like this:
Edit: Small modification to the filter criteria.
Thanks a lot sfdcfox. I paste my trigger code in case it might help someone:
Cheers!
Antonio