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 

Error: Maximum trigger depth exceeded

HI All,


 I am  getting an error  Maximum trigger depth exceeded .Please help.


trigger UpdateContact on Case (before insert,after insert) {
 if (( == 1)&&([0].Source_ID__c !=null)){
    list<Contact> con = new list<Contact>([Select c. Employee_ID__c, c.Id, c.Email From Contact c where c.Employee_ID__c =:[0].Source_ID__c]);
    system.debug('----con[0].Id-------'+con[0].Id);[0].ContactID = con[0].Id;


   list<Case> clist = new list<Case>();
       clist.add(new Case(  Tool__c= c.Tool__c,Source_ID__c= c.Source_ID_2__c,));
     insert clist;


u are going in to infinete loop..write the same logic in a class and stop the process once ur custom insertion is done using static variable....

Thanks for your reply.Can you plss modify my trigger


this is the sample check it out and try

trigger ProcessAccount on Account (before insert, before update) {
Set<String> uniqueNames = new Set<String>();
if (!ProcessorControl.inFutureContext) {
for (Account a :

if (!uniqueNames.isEmpty())



public class AccountProcessor {

@ublic static void processAccounts(Set<String> names) {
// list to store the accounts to update
List<Account> accountsToUpdate = new List<Account>();
// iterate through the list of accounts to process
for (Account a : [Select Id, Name From Account where UniqueName__c IN :names]) {
// ... do your account processing
// add the account to the list to update
ProcessorControl.inFutureContext = true;
// update the accounts
update accountsToUpdate;