You need to sign in to do that
Don't have an account?
JLockard
Apex Trigger for Manager Email
Hello,
I am attempting to write an Apex trigger to look up the ManagerID for the record owner, the post the Manager email address into a custom field on the current record.
I'm new to Apex and having difficulty developing this code, which seems like it should be relatively simple.
Anyone have examples of such functionality?
Thanks!
J
The steps I followed to do this are:
Create a custom LOOKUP field on the OBJECT (let's call it AssignedOwner)
Create an APEX trigger to set the LOOKUP field as the record OWNER (AssignedOwner__c = Account.OwnerID)
Create an email field on the OBJECT (let's call it ManagerEmail)
Create a workflow update to run a FIELD UPDATE on the ManagerEmail and reference AssignedOwner__r.Manager.Email
Here's the trigger - I think you can figure out the rest (It's probably crappy code, so developers, please recommend fixes - but it gets the job done!)
trigger MyObjectOwnerLookupThingy on Account(before insert, before update) {
For (Account Account_This : System.Trigger.New)
{
Account_This.AccountOwner__c = Account_This.OwnerID;
}
}
Enjoy!
-Aaron