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
Sam SatterfieldSam Satterfield 

After Insert Trigger, No Errors, Not Running.

The Trigger is supposed to run after another trigger has created the record. When the record is inserted, the trigger is called; but nothing happens. The trigger gives no errors and I have no idea why it doesn't work. Any help is greatly appreciated.
trigger TAMOCon_AssociatedChildUpdate on Topline_Account_Management__c (after insert) 
{
      
   for (Topline_Account_Management__c Tamo : Trigger.New)
   {
		List<contact> conToUpdate = new list <Contact>();

   for(contact Con : [select Id,D_T_TAMO_ID__c,LLC_AgreementNew__c
                      from Contact where D_T_TAMO_ID__c=:TAMO.Topline_Account_Management_Record_ID__c]) 
{ 

						Con.LLC_AgreementNew__c = 'Signed';
 						conToUpdate.ADD(Con);
                        update conToUpdate;
}}}
Best Answer chosen by Sam Satterfield
surasura
actually your trigger is running , but query is not returning 0 contacts . make sure there there are contacts and your quey criteria is correct
 
13:33:28.137 (137288922)|SOQL_EXECUTE_BEGIN|[10]|Aggregations:0|SELECT Id, D_T_TAMO_ID__c, LLC_AgreementNew__c FROM Contact
058
13:33:28.167 (167044738)|SOQL_EXECUTE_END|[10]|Rows:0

 

All Answers

ManojjenaManojjena
Hi Sam ,

Create debug an dcheck the debug statement is debug log .I have optimised the code ,Removed query and DML from for loop .

Try and let me know if it helps .
 
trigger TAMOCon_AssociatedChildUpdate on Topline_Account_Management__c (after insert) {
   List<contact> conToUpdate = new list <Contact>();
   Set<id> accManagementIdSet=new Set<Id>();   
   for (Topline_Account_Management__c Tamo : Trigger.New){
     System.debug('********************Trigger is executing***************************');
	accManagementIdSet.add(tamo.Topline_Account_Management_Record_ID__c);
   }
   for(contact con : [SELECT Id,D_T_TAMO_ID__c,LLC_AgreementNew__c 
                      FROM Contact WHERE D_T_TAMO_ID__c IN : accManagementIdSet]) { 
         con.LLC_AgreementNew__c = 'Signed';
 		 conToUpdate.ADD(Con);
   }
   try{
   update conToUpdate;
   }catch(DmlException de){
      System.debug(de);
   }
}

Thanks 
Manoj
Sam SatterfieldSam Satterfield
Thanks for replying so quickly; but unfortunately, it still didn't work, or at least as I believe it would/should. 

Please find the debug below:
 
33.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
13:33:28.118 (118243625)|EXECUTION_STARTED
13:33:28.118 (118280454)|CODE_UNIT_STARTED|[EXTERNAL]|01q19000000Ck7C|TAMOCon_AssociatedChildUpdate on Topline_Account_Management trigger event AfterInsert for [a0k19000000T9re]
13:33:28.118 (118370699)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
13:33:28.119 (119122501)|HEAP_ALLOCATE|[71]|Bytes:3
13:33:28.119 (119172470)|HEAP_ALLOCATE|[76]|Bytes:152
13:33:28.119 (119201906)|HEAP_ALLOCATE|[272]|Bytes:408
13:33:28.119 (119237969)|HEAP_ALLOCATE|[285]|Bytes:408
13:33:28.119 (119271974)|HEAP_ALLOCATE|[379]|Bytes:48
13:33:28.119 (119318550)|HEAP_ALLOCATE|[131]|Bytes:6
13:33:28.119 (119372799)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:33:28.119 (119389795)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
13:33:28.119 (119401173)|VARIABLE_SCOPE_BEGIN|[1]|this|TAMOCon_AssociatedChildUpdate|true|false
13:33:28.119 (119461377)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x39ca483d
13:33:28.119 (119503750)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
13:33:28.119 (119513634)|VARIABLE_SCOPE_BEGIN|[1]|this|TAMOCon_AssociatedChildUpdate|true|false
13:33:28.119 (119539297)|VARIABLE_ASSIGNMENT|[1]|this|{}|0x39ca483d
13:33:28.119 (119550686)|STATEMENT_EXECUTE|[1]
13:33:28.119 (119556236)|STATEMENT_EXECUTE|[4]
13:33:28.119 (119702443)|HEAP_ALLOCATE|[4]|Bytes:4
13:33:28.119 (119819520)|SYSTEM_CONSTRUCTOR_ENTRY|[4]|<init>()
13:33:28.119 (119860449)|SYSTEM_CONSTRUCTOR_EXIT|[4]|<init>()
13:33:28.119 (119910733)|HEAP_ALLOCATE|[50]|Bytes:5
13:33:28.119 (119945995)|HEAP_ALLOCATE|[56]|Bytes:5
13:33:28.119 (119965186)|HEAP_ALLOCATE|[63]|Bytes:7
13:33:28.120 (120015288)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:33:28.120 (120055043)|VARIABLE_ASSIGNMENT|[4]|this.conToUpdate|{"serId":1,"value":[]}|0x39ca483d
13:33:28.120 (120063845)|STATEMENT_EXECUTE|[5]
13:33:28.120 (120083584)|HEAP_ALLOCATE|[5]|Bytes:4
13:33:28.120 (120115016)|SYSTEM_CONSTRUCTOR_ENTRY|[5]|<init>(Integer)
13:33:28.120 (120144937)|SYSTEM_CONSTRUCTOR_EXIT|[5]|<init>(Integer)
13:33:28.120 (120207999)|VARIABLE_ASSIGNMENT|[5]|this.accManagementIdSet|{"serId":1,"value":[]}|0x39ca483d
13:33:28.120 (120357056)|SYSTEM_METHOD_ENTRY|[6]|List<Topline_Account_Management__c>.iterator()
13:33:28.120 (120541498)|SYSTEM_METHOD_EXIT|[6]|List<Topline_Account_Management__c>.iterator()
13:33:28.120 (120584300)|SYSTEM_METHOD_ENTRY|[6]|system.ListIterator.hasNext()
13:33:28.120 (120623969)|HEAP_ALLOCATE|[6]|Bytes:5
13:33:28.120 (120638614)|SYSTEM_METHOD_EXIT|[6]|system.ListIterator.hasNext()
13:33:28.120 (120677906)|VARIABLE_SCOPE_BEGIN|[6]|Tamo|Topline_Account_Management__c|true|false
13:33:28.136 (136099709)|VARIABLE_ASSIGNMENT|[6]|Tamo|{"Cost_Effective_Video (3 more) ...":false,"Appointment_Reminder (11 more) ...":"Pending Formstack Su (8 more) ...","LastModifiedDate":"2015-06-04T17:33:28.000Z","Physicians_experts_o (21 more) ...":false,"D_T_Formstack_Link__ (1 more) ...":"https://femwell.form (126 more) ...","AccentHealth_Status_ (2 more) ...":"Not Started","Services_Active_RLT_ (2 more) ...":false,"Physicians_provide_a (20 more) ...":false,"TopLine_MD_Safety_Vi (6 more) ...":false,"D_T_Kiosk_Status__c":false,"Checked_for_Qualific (21 more) ...":false,"Media_Opp_Informatio (14 more) ...":false,"TopLine_MD_Access_to (14 more) ...":false,"Physicians_featurabl (15 more) ...":false,"Additional_Video_1__ (1 more) ...":false,"D_T_NAMLP_Flag__c":false,"RPT_Due_Date_set__c":false,"Account_LLC_Address_ (2 more) ...":", , , ","D_T_App_Reminders__c":false,"Opted_Out_of_Monthly (16 more) ...":false,"Relatient_Status__c":"Not Started","D_T_Date_of_Last_Sub (10 more) ...":false,"CreatedById":"0051400000BOtdPAAT","Physicians_contacted (21 more) ...":false,"Services_Active_RPT_ (2 more) ...":false,"IsDeleted":false,"Id":"a0k19000000T9reAAC","Re_submission_Accent (9 more) ...":false,"D_T_MO_Info_Submitte (4 more) ...":false,"OwnerId":"0051400000BOtdPAAT","D_T_MD_Pay__c":false,"D_T_Acc_Name__c":"Test Acc 1","D_T_Due_Date_Set__c":false,"Re_Submission_Reputa (7 more) ...":false,"D_T_Formstack_Submis (7 more) ...":false,"Shown_Interest_in_Me (20 more) ...":false,"SystemModstamp":"2015-06-04T17:33:28.000Z","RLT_Due_Date_Set__c":false,"D_T_First_Submission (8 more) ...":false,"Agreed_to_Terms_and_ (13 more) ...":false,"MD_Pay__c":"Pending Formstack Su (8 more) ...","Topline_Services_Ord (12 more) ...":"No Order","DX_Center_VideoCB__c":false,"Services_Active_ACH_ (2 more) ...":false,"TopLine_MD_Technolog (10 more) ...":false,"Kiosk_Quantity__c":0,"LastModifiedById":"0051400000BOtdPAAT","Outstanding_patient_ (16 more) ...":false,"D_T_Do_Not_Touch__c":true,"Topline_Account_Mana (19 more) ...":"a0k19000000T9re","Record_Status__c":"Active","Name":"Test Acc 1","Account_LLC_Record_N (6 more) ...":"00119000006dDoDAAU","Media_Opp_Informatio (13 more) ...":false,"Re_submission_Relati (6 more) ...":false,"Reputation_com_Kiosk (10 more) ...":"Not Started","CreatedDate":"2015-06-04T17:33:28.000Z","D_T_TopLine_MD_TV2__ (1 more) ...":false,"Custom_PAsCB__c":false,"Additional_Video_2__ (1 more) ...":false,"D_T_TopLine_MD_TV__c":false}|0x2e599649
13:33:28.136 (136137327)|STATEMENT_EXECUTE|[6]
13:33:28.136 (136143076)|STATEMENT_EXECUTE|[7]
13:33:28.136 (136155282)|HEAP_ALLOCATE|[7]|Bytes:67
13:33:28.136 (136206678)|SYSTEM_METHOD_ENTRY|[7]|System.debug(ANY)
13:33:28.136 (136249458)|USER_DEBUG|[7]|DEBUG|********************Trigger is executing***************************
13:33:28.136 (136263149)|SYSTEM_METHOD_EXIT|[7]|System.debug(ANY)
13:33:28.136 (136281317)|STATEMENT_EXECUTE|[8]
13:33:28.136 (136373770)|SYSTEM_METHOD_ENTRY|[8]|Set<Id>.add(Object)
13:33:28.136 (136426944)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:33:28.136 (136450271)|SYSTEM_METHOD_EXIT|[8]|Set<Id>.add(Object)
13:33:28.136 (136467663)|SYSTEM_METHOD_ENTRY|[6]|system.ListIterator.hasNext()
13:33:28.136 (136492185)|HEAP_ALLOCATE|[6]|Bytes:5
13:33:28.136 (136505152)|SYSTEM_METHOD_EXIT|[6]|system.ListIterator.hasNext()
13:33:28.136 (136531963)|VARIABLE_ASSIGNMENT|[6]|Tamo|null|
13:33:28.136 (136543303)|HEAP_ALLOCATE|[10]|Bytes:91
13:33:28.136 (136568979)|HEAP_ALLOCATE|[10]|Bytes:4
13:33:28.136 (136586400)|HEAP_ALLOCATE|[10]|Bytes:7
13:33:28.137 (137288922)|SOQL_EXECUTE_BEGIN|[10]|Aggregations:0|SELECT Id, D_T_TAMO_ID__c, LLC_AgreementNew__c FROM Contact 
13:33:28.167 (167044738)|SOQL_EXECUTE_END|[10]|Rows:0
13:33:28.167 (167168062)|SYSTEM_METHOD_ENTRY|[10]|Database.QueryLocator.iterator()
13:33:28.167 (167425402)|HEAP_ALLOCATE|[10]|Bytes:49
13:33:28.167 (167445471)|HEAP_ALLOCATE|[10]|Bytes:8
13:33:28.167 (167475791)|SYSTEM_METHOD_ENTRY|[7]|QueryLocatorIterator.QueryLocatorIterator()
13:33:28.167 (167486447)|STATEMENT_EXECUTE|[7]
13:33:28.167 (167503880)|SYSTEM_METHOD_EXIT|[7]|QueryLocatorIterator
13:33:28.167 (167523307)|HEAP_ALLOCATE|[10]|Bytes:28
13:33:28.167 (167547618)|HEAP_ALLOCATE|[10]|Bytes:8
13:33:28.167 (167555104)|HEAP_ALLOCATE|[10]|Bytes:8
13:33:28.167 (167567372)|VARIABLE_SCOPE_BEGIN|[15]|this|Database.QueryLocatorIterator|true|false
13:33:28.167 (167629246)|VARIABLE_ASSIGNMENT|[15]|this|{}|0x2bc83fec
13:33:28.167 (167639364)|VARIABLE_SCOPE_BEGIN|[15]|values|List<SObject>|true|false
13:33:28.167 (167652692)|VARIABLE_ASSIGNMENT|[15]|values|null|
13:33:28.167 (167659493)|VARIABLE_SCOPE_BEGIN|[15]|ql|Database.QueryLocator|true|false
13:33:28.167 (167690450)|VARIABLE_ASSIGNMENT|[15]|ql|{"query":"SELECT Id, D_T_TAMO_ (71 more) ..."}|0x67dcb568
13:33:28.167 (167701087)|VARIABLE_SCOPE_BEGIN|[15]|totalNumRecords|Integer|false|false
13:33:28.167 (167714388)|VARIABLE_ASSIGNMENT|[15]|totalNumRecords|0
13:33:28.167 (167721390)|VARIABLE_SCOPE_BEGIN|[15]|queryMoreSize|Integer|false|false
13:33:28.167 (167732244)|VARIABLE_ASSIGNMENT|[15]|queryMoreSize|50000
13:33:28.167 (167762397)|HEAP_ALLOCATE|[16]|Bytes:6
13:33:28.167 (167811771)|VARIABLE_SCOPE_BEGIN|[2]|this|system.ApexBaseClass|true|false
13:33:28.167 (167843681)|VARIABLE_ASSIGNMENT|[2]|this|{}|0x2bc83fec
13:33:28.167 (167886966)|VARIABLE_ASSIGNMENT|[16]|this.ql|{"query":"SELECT Id, D_T_TAMO_ (71 more) ..."}|0x2bc83fec
13:33:28.167 (167908317)|VARIABLE_ASSIGNMENT|[17]|this.totalNumRecords|0|0x2bc83fec
13:33:28.167 (167921760)|HEAP_ALLOCATE|[18]|Bytes:4
13:33:28.167 (167938195)|VARIABLE_ASSIGNMENT|[18]|this.count|0|0x2bc83fec
13:33:28.167 (167948506)|HEAP_ALLOCATE|[19]|Bytes:4
13:33:28.167 (167964167)|VARIABLE_ASSIGNMENT|[19]|this.index|0|0x2bc83fec
13:33:28.167 (167984818)|VARIABLE_ASSIGNMENT|[20]|this.buffer|null|0x2bc83fec
13:33:28.168 (168001370)|VARIABLE_ASSIGNMENT|[21]|this.buffer|null|0x2bc83fec
13:33:28.168 (168020495)|VARIABLE_ASSIGNMENT|[22]|this.queryMoreSize|50000|0x2bc83fec
13:33:28.168 (168037524)|HEAP_ALLOCATE|[10]|Bytes:28
13:33:28.168 (168049212)|SYSTEM_METHOD_EXIT|[10]|Database.QueryLocator.iterator()
13:33:28.168 (168076376)|SYSTEM_METHOD_ENTRY|[10]|Database.QueryLocatorIterator.hasNext()
13:33:28.168 (168090800)|VARIABLE_SCOPE_BEGIN|[25]|this|Database.QueryLocatorIterator|true|false
13:33:28.168 (168132536)|VARIABLE_ASSIGNMENT|[25]|this|{"count":0,"index":0,"ql":{"query":"SELECT Id, D_T_TAMO_ (71 more) ..."},"queryMoreSize":50000,"totalNumRecords":0}|0x2bc83fec
13:33:28.168 (168169601)|SYSTEM_METHOD_EXIT|[10]|Database.QueryLocatorIterator.hasNext()
13:33:28.168 (168195719)|VARIABLE_ASSIGNMENT|[10]|con|null|
13:33:28.168 (168204961)|STATEMENT_EXECUTE|[10]
13:33:28.168 (168237516)|STATEMENT_EXECUTE|[15]
13:33:28.168 (168242783)|STATEMENT_EXECUTE|[15]
13:33:28.168 (168246608)|STATEMENT_EXECUTE|[16]
13:33:28.168 (168412375)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
13:33:28.240 (168449099)|CUMULATIVE_LIMIT_USAGE
13:33:28.240|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 50
  Number of Mobile Apex push calls: 0 out of 10

 
surasura
actually your trigger is running , but query is not returning 0 contacts . make sure there there are contacts and your quey criteria is correct
 
13:33:28.137 (137288922)|SOQL_EXECUTE_BEGIN|[10]|Aggregations:0|SELECT Id, D_T_TAMO_ID__c, LLC_AgreementNew__c FROM Contact
058
13:33:28.167 (167044738)|SOQL_EXECUTE_END|[10]|Rows:0

 
This was selected as the best answer
Sam SatterfieldSam Satterfield
I see, then this code cannot run as an Insert. It does run as an update though, I guess the record isn’t truly inserted yet and cannot query for itself. Thank you for your help, I greatly appreciate it. Best, Sam S.