You need to sign in to do that
Don't have an account?

Access of the query results
Hi,
I have this code :
global void execute(SchedulableContext ctx)
{
public List<String> account_email{get;set;}
public Map<string,string> Map_usr{get;set;}
Map_usr=new Map<string,string>();
account =[Select (Select Etape_de_cr_ation__c From Opportunities where Etape_de_cr_ation__c='Etape2'),
(Select Id, Email, Destinataire__c From Contacts where Destinataire__c='Oui') From Account a];
for(Account c:account)
{
system.debug('____id__'+c.id+'____Email_____'+c.Email+'___DATE_______'+c.Destinataire__c);
//error at this line :Save error: Invalid field Email for SObject Account
Map_usr.put(c.id,c.Email);
if(c.Email!=null)
account_email.add(c.Email);
}
if(account_email.size()>0)
sendmail(account_email);
}
my question is: how to recover the data (email) of the query?
thanks for your help!
cordially
moh.
Hi,
You have to use the inner loop for access the email and Destinataire__c field. Because these fields are exist in child object not in account object.
Try the below code snippet as reference:
for(Account c:account)
{
for(Contact dd:c.contacts)
{
system.debug('____id__'+c.id+'____Email_____'+dd.Email+'___DATE_______'+dd.Destinataire__c);
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
i tested your code and i have this error :Save error: Invalid field Email for SObject Account
you have another suggestion?
thanks
cordially
moh.
HI Moh,
Please try this code...