You need to sign in to do that
Don't have an account?
Chinmay Abhangrao
Hello i Want the Email Id of Account Owner who owns the Particular case.... how can i do this? any soql query?
If(Trigger.isinsert && Trigger.isafter){
set<id> setid=new set<id>();
for(Case c:trigger.new )
{
setid.add(c.AccountId);
}
list<account> acctoup=new list<account>();
map<id,Account> acclist=new map<id,Account>([select id,Current_Issue__c,Past_Issue__c,Total_Issue_Count__c from account where id=:setid]);
for(Case c:trigger.new)
{
account a=acclist.get(c.AccountId);
account a=acclist.get(c.AccountId);
String EmailIdOfOwner =[SELECT Account.Owner.Email FROM Case WHERE c.id =a.Id]; // Something Wrong here
}
set<id> setid=new set<id>();
for(Case c:trigger.new )
{
setid.add(c.AccountId);
}
list<account> acctoup=new list<account>();
map<id,Account> acclist=new map<id,Account>([select id,Current_Issue__c,Past_Issue__c,Total_Issue_Count__c from account where id=:setid]);
for(Case c:trigger.new)
{
account a=acclist.get(c.AccountId);
account a=acclist.get(c.AccountId);
String EmailIdOfOwner =[SELECT Account.Owner.Email FROM Case WHERE c.id =a.Id]; // Something Wrong here
}
Hi
Chinmay Abhangrao
Try this code
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay
All Answers
Hi
Chinmay Abhangrao
Try this code
if you found this answer helpful then please mark it as best answer so it can help others.
Thanks
Akshay
; /EmailSentToOwnert is class contains all the information required for the email //sending process but it required an email address, subject, body ..can we pass this //emailidOwner to this method.
EmailSendToOwner obj=new EmailSendToOwner()
String EmailIdOfOwner =acclist.get(c.AccountId).Owner.Email;
obj.sendMail(EmailIdOfOwner, 'subject', 'body');
List<Case> caseList = [Select Id,Account.Owner.Email from Case];
for(Case eachCase : caseList){
System.debug('caseList:'+eachCase.Account.Owner.Email);
}
So for you just need to add the following to get the value of email. You no need to do an extra query. NOTE: make sure account owner has email populated in his record.
String EmailIdOfOwner = = c.Account.Owner.Email;
Please mark it best if it helps you. Thanks in advance.
Regards,
Pawan Kumar
if you find this answer helpful then please mark it as best answer so it can help others.
Thanks Akshay