For Example there's a trigger on Account (after update ) in it I update the address of 10000 contacts(max for all accounts combined) , now I have an trigger(after update) on contact for each contact i update campaign record . Will the Account and contact trigger be running in different context or apex transactions ? and if they run in same context will it generate an error due to some DML limit

1 Answer 1


If trigger starts working from another trigger, they are executed in same transaction.

It can be easily tested by these samples:

1st Account trigger that calls Opportunity trigger:

trigger AccountTrigger on Account (after insert) {
    //in 1st trigger you see opps update, so they call 2nd trigger
    system.debug('1st trigger: before SOQL: ' + Limits.getQueries());
    List<Opportunity> opps = [SELECT Id FROM Opportunity];
    system.debug('1st trigger: after SOQL: ' + Limits.getQueries());
    update opps;

2nd Opportunity trigger:

trigger OpportunityTrigger on Opportunity (before update) {
    system.debug('2nd trigger: before SOQL: ' + Limits.getQueries());
    List<Organization> org = [SELECT Id FROM Organization];
    system.debug('2nd trigger: after SOQL: ' + Limits.getQueries());

Debug logs:

enter image description here

So as you can see, they both share limits in one transaction.

You must log in to answer this question.

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