+ Start a Discussion
Bhuvanakruthi MudholeBhuvanakruthi Mudhole 

write a trigger on case where on creation case record you have to populate email address from related account record

Pradeep SinghPradeep Singh
Are you using any custom field for email or you are using contact email on case object.?
Bhuvanakruthi MudholeBhuvanakruthi Mudhole
Custom field for email on case object
v varaprasadv varaprasad
Hi Bhuvana,

Please check following sample code : 

trigger UpdateAccEmailOnCase on Case (before insert) {
    set<id> accids = new set<id>();
    for(case c : trigger.new){
        if(c.accountid != null){
    list<account> lstAccs = [select id,name,Email__c from account where id in : accids];
    map<id,account> mapAccData = new map<id,account>(lstAccs);
    for(case c : trigger.new){
        if(c.accountid != null && mapAccData.containsKey(c.accountid)){
            c.email__c = mapAccData.get(c.accountid).Email__c; 


Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

@For Support: varaprasad4sfdc@gmail.com