You need to sign in to do that
Don't have an account?
MariP
System.ListException: List index out of bounds: 0
Hi,
I wanted to populate a list incrementing myself the meter :
public with sharing class CSR_CORE_RequestTriggers_SendSingleEmail {
// Collections
public list<string> lTypesContactList {get;set;}
public void SendEmail(List<Request__c> closedRequestList){
System.debug('## Start class ## CSR_CORE_RequestTriggers_SendSingleEmail - ligne 14 ' + UserInfo.getName());
for (Request__c closedRequest:closedRequestList){
// GET EMAIL ADDRESSES
Boolean resultTest;
//put values of multi-select picklist field into a list
try{
list<string> lTypesContactList = closedRequest.Contact_types_for_Email__c.split(';', 15);
// for every type of contact of the list, find its email address in Contact external
Integer count = 0 ;
for (String sTypesContact : lTypesContactList) {
System.debug('valeur de sTypesContact : ' + sTypesContact);
try{
Contact_external__c acc_Contact_External = [select Name, Email__c from Contact_external__c
where Account__c = :closedRequest.Entity__c
and title__c = :sTypesContact limit 1 ];
// it is an external contact
System.debug('valeur de acc_Contact_External : ' + acc_Contact_External);
if(acc_Contact_External.Name != null){
// contact has an email address
if(acc_Contact_External.email__c != null){
// System.debug('valeur de count = [' + count + ']');
// lEmailAddressesList.add(acc_Contact_External.email__c); *
lEmailAddressesList[count] = (acc_Contact_External.email__c);
count++;
}
}
} catch (System.QueryException e) {
System.debug('passage dans le Catch');
// not found in external contact
resultTest = sTypesContact.contains('lanner');
// is it a planner ?
System.debug('valeur de resultTest - Planner : ' + resultTest);
if(resultTest == true ) {
Request__c acc_Request = [select Id, Entity__r.Supply_planner_contact__r.Email
from Request__c where Id = :closedRequest.Id];
System.debug('valeur de acc_Request : ' + acc_Request);
System.debug('valeur de acc_Request.Entity__r.Supply_planner_contact__r.Email : ' + acc_Request.Entity__r.Supply_planner_contact__r.Email);
if(acc_Request.Entity__r.Supply_planner_contact__r.Email != null){
System.debug('valeur de Planner email : ' + acc_Request.Entity__r.Supply_planner_contact__r.Email);
// lEmailAddressesList.add(acc_Request.Entity__r.Supply_planner_contact__r.Email);
lEmailAddressesList[count] = (acc_Request.Entity__r.Supply_planner_contact__r.Email);
count++;
}
} else {
resultTest = sTypesContact.contains('ield Service');
System.debug('valeur de resultTest - FSM : ' + resultTest);
// is it a field service manager ?
if(resultTest == true ) {
Request__c acc_Request = [select Id, Entity__r.Field_service_manager_contact__r.Email
from Request__c where Id = :closedRequest.Id];
System.debug('valeur de acc_Request : ' + acc_Request);
System.debug('valeur de acc_Request.Entity__r.Field_service_manager_contact__r.Email : ' + acc_Request.Entity__r.Field_service_manager_contact__r.Email);
if(acc_Request.Entity__r.Field_service_manager_contact__r.Email != null){
System.debug('valeur de FSM email : ' + acc_Request.Entity__r.Field_service_manager_contact__r.Email);
// lEmailAddressesList.add(acc_Request.Entity__r.Field_service_manager_contact__r.Email);
lEmailAddressesList[count] = (acc_Request.Entity__r.Field_service_manager_contact__r.Email);
count++;
}
}
}
} // try (1)
} // for lTypesContactList
System.debug('valeur de lEmailAddressesList après boucle lecture : ' + lEmailAddressesList);
(I used first .add method, but I add only the last value)
Does anybody can tell me what I am doing wrong ?
Thank you !
Marie
Forget this message...
I probably have a problem in the access to my datas....
Sorry
All Answers
in fact, using the .add method, I had not the only last one, but maybe the only FIRST one
Forget this message...
I probably have a problem in the access to my datas....
Sorry