Ideally, it is recommended that you create APEX Code to reference the opportunity history. This will then access the old owner’s details.
However, a work-around can be accomplished by a combination of workflow and custom field.
The general outline of the solution can found below:
- First create a new hidden email field on your object in question:
- The next step is to create a workflow. The workflow action should be update to this field with the previous owners email address.
- However, there is a catch. This list must be maintained manually. This is because you have to get the ID's of all active users, and then their email address, and enter these into a case statement
- For Enterprise customers, you can get the id's and emails easily with the DataLoader.
- The workflow criteria must be set to the formula type.
- The criteria for the workflow is:
- ISCHANGED( OwnerId )
- The first action is:
- A workflow field update, based on a formula. An example of the formula would be like this:
- Case((PRIORVALUE( OwnerId )),"00520000000kSl8","user1.company.com","00520000000rahW","firstname.lastname@example.org","Update workflow with new email addresses")
- Here you put in each users ID, and then their email address. This will check what the id of the prior user was, and copy the email address of that prior user into the hidden email field we created. The message at the end will appear only when someone has an ID not recognized by the rule. This will alert the other admins to update the rule and you could have another workflow based on this set to trigger an email to them.
- The second action is:
- As part of the same workflow rule, create a second action, but this time as an email.
- In the email recipient field, put both the 'record owner' and the email address contained within our hidden email field. This will send the email template to both the new and old users.
- Note: If you wanted a separate template to go to the old owner, create a third action of an email only going to the old user. Now you could say something like: Your opportunity has now been assigned to user x (and provide a link)
Because it's a field update, you'll have to change the owner first to get a data in the hidden 'previous owner email' field. Then when you change the owner again, an email will get sent to the new owner, and the email address of the previous owner field.