Skip to main content
1 of 2

Apex trigger error message

Here is the error that drives me insane Apex trigger SDocsSendToSpeaker caused an unexpected exception [..] SDocsSendToSpeaker: execution of BeforeUpdate caused by: System.ListException: List index out of bounds: 0: Trigger.SDocsSendSpeaker: line 5, column 1

I have a similar apex trigger on another custom object that works perfectly fine and these two objects are pretty much identical, the logic is identical. drives me insane. not to mention I am not very good at this and am a beginner admin. Thank you for helping me out!

trigger SDocsSendToSpeaker on EOSummit__c(before update) {

for (EOSummit__c l : Trigger.new) if (l.Contract_Status__c == 'Send to speaker'){ string coverletteTID = [select Template_ID__c from SDOCLocalTemplate__c where name = 'EmailForSpeakerContract'][0].Template_ID__c; string contractTID= [select Template_ID__c from SDOCLocalTemplate__c where name = 'Contract EO Summit'][0].Template_ID__c; SDOC.SDBatch.CreateSDocSync(UserInfo.getSessionId(), UserInfo.getUserName(), 'id='+l.id+'&Object=EOSummit__c&doclist='+coverletteTID +','+contractTID+'&oneclick=1&sendEmail=1'); l.Contract_Status__c = 'Deployed'; } }