• cutspmjerry
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies

 I have attached a code snippet below that is confusing me.  When the select statement returns a row the debug statement is executed and the rest of the code is executed also.  But when no row is returned for the select statement everything seems to stop.  Even the debug statement is not executed.  Why is this?  I tried putting in a try-catch statement to catch a dmlexception but nothing was caught.

 

Thanks in advance.

 

 public void ProductGroupChanged() {

  Payment_Type_Group__c ptg;

  ptg = [ SELECT ID FROM Payment_Type_Group__c WHERE Product_Group__c =:ProductGroupID AND Default__c = true LIMIT 1];

  System.debug('Made it here!');

   if (ptg != null) {

      this.opg.Product_Group__c = ProductGroupID;

      this.opg.Payment_Type_Group__c = ptg.ID;

  } else {

      this.opg.Product_Group__c = null;       this.opg.Payment_Type_Group__c = null;

  }

}

I am going through some examples in the Developer guide and can't get passed an error.  The code is a trigger that adds a record in another table based on the value of a field that has been changed.  I really don't see how I am exceeding the trigger depth when I am simply inserting a record into a seperate table. 

 

Also, the exceptions are not being caught.  The error message I receive does not come from my code.

 

Any help would be appreciated!

 

 

 

Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger assignInterviewers caused an unexpected exception, contact your administrator: assignInterviewers: maximum trigger depth exceeded Job_Application trigger event AfterUpdate for a02A00000018Q5D Job_Application trigger event

 

trigger assignInterviewers on Job_Application__c (after insert, after update) {

   List<Review__c> addReviews = new List<Review__c>();

    for (Job_Application__c JA : trigger.new){

      List<User> selectedReviewers = [select ID from user limit 1];

        if (JA.status__c == 'New') {

         ID jobID = JA.ID;

         For ( User u : selectedReviewers) {            addReviews.add(new Review__c( Job_Application__c = jobID, reviewer__c = u.ID, rating__c = 3));

         }

           try {

              insert addReviews;

         }

           catch (DmlException de) {               for (Integer i = 0; I < de.getNumDml(); i++) {

              JA.addError('dmlexption' + de.getDmlMessage(i));

           }

       }

         finally {          JA.addError('made it to finally');

       }

    }

  }

}

I have seen this issue in the forums about the "New" and "Edit" pages, but my VF page does display in the dropdown for those two buttons.

 

What is different about overriding the "List" link versus "New" or "Edit"?

 

Thanks 

 I have attached a code snippet below that is confusing me.  When the select statement returns a row the debug statement is executed and the rest of the code is executed also.  But when no row is returned for the select statement everything seems to stop.  Even the debug statement is not executed.  Why is this?  I tried putting in a try-catch statement to catch a dmlexception but nothing was caught.

 

Thanks in advance.

 

 public void ProductGroupChanged() {

  Payment_Type_Group__c ptg;

  ptg = [ SELECT ID FROM Payment_Type_Group__c WHERE Product_Group__c =:ProductGroupID AND Default__c = true LIMIT 1];

  System.debug('Made it here!');

   if (ptg != null) {

      this.opg.Product_Group__c = ProductGroupID;

      this.opg.Payment_Type_Group__c = ptg.ID;

  } else {

      this.opg.Product_Group__c = null;       this.opg.Payment_Type_Group__c = null;

  }

}