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

Copy data from one Object to another Object using Lookup Field
I am trying to create a trigger and class using Apex that will take data from a couple fields on the user record and copy them into fields on an Opportunity using the Opportunity Owner lookup field. From within the opportunity I need to lookup the opportunity owner's user record and pull over the Title, Department, and Email from the user record and put it in the opportunity record. I appreciate the help.
you code would be something like this
HTH
trigger OpportunityOwnersManagerEmail on Opportunity (before insert, before update) {
String userMgr;
for(Opportunity opp:Trigger.new){
//get user info
userMgr = [select Manager_s_Email__c from User where id=:opp.Owner];
//set the data
opp.Manager_s_Email__c = userMgr.Manager_s_Email__c;
}
}
Thank you for your help!
.... where id=
@Mayrich1
I know it has been a while since this post but I was wondering if you could post what you figured out?
I'm getting the same error message.
thank you