0

I am trying to insert a new custom object called Aid if 2 CheckBoxes in an account are checked.

here is my trigger:

trigger Aid on Account (before update) {
for(Account acc: Trigger.new) {

    if(acc.is_old == true && acc.is_poor  == true) {
        Aid aid = new Aid();
        aid.Pogram_name__c   = 'a0RD000000E****';
        aid.Item__c          = 'a10D0000000****';
        aid.Supplier__c      = 'a0zD0000000****';
        aid.Household__c     =  acc.id;
        insert aid;
    }

}
}

I am getting this error:

Apex trigger Aid caused an unexpected exception, contact your administrator: Aidexecution of BeforeUpdate caused by: System.DmlException: Insert failed.

First exception on row 0; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 001D000001x****) is currently in trigger Aid therefore it cannot recursively update itself: []: Trigger.Aid: line 10, column 1**

what am i doing wrong???

  • Is there any trigger on Aid. Also there should be __c in Aid name? – Ashwani Apr 5 '17 at 8:52
  • @Ashwani , yes there should be _ c. i just shortened it for here.. no triggers on aid.. – maor.v Apr 5 '17 at 8:57
  • Try with an after update. – Martin Lezer Apr 5 '17 at 9:16
  • @MartinLezer i get this::Apex trigger Aid caused an unexpected exception, contact your administrator: Aid execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, PersonAccount trigger event AfterUpdate for [001D000001x****] PersonAccount trigger event AfterUpdate for [001D000001x**** PersonAccount trigger event AfterUpdate for ............................................................... PersonAccount trigger event AfterUpdate for [001D000001x****]: []: Trigger.Aid: line 12, column 1 – maor.v Apr 5 '17 at 9:23
  • I am pretty sure that there is trigger on Aid, that cause an update on child AID records (or flow/processbuilder/workflow etc), so loop appears – kurunve Apr 5 '17 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.