trigger userDetailupdateFromAccount on Account (before update) {
//Get all accounts
Map<ID,Account> acc = new Map<ID,Account>([Select OwnerID,Name FROM Account WHERE ID IN : Trigger.oldMap.keyset()]);
//Get all users
Map<ID,user> allUsers = new Map<ID,User>([Select ID,Name,email from User where ID IN : acc.keyset()]);
Map<ID,User> accToUser = new Map<ID,User>();
for(Account a : trigger.new){
User u = allUsers.get(a.OwnerID);
// a.description__c = u.Email;
system.debug('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'+allUsers+acc );
system.debug('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'+acc.keyset());
}
}
Map acc = new Map([Select OwnerID,Name FROM Account WHERE ID IN : Trigger.oldMap.keyset()]); - is setting AccountID to Map. How can I assign it to OwnerID instead of AccountID ?
Thanks