+ Start a Discussion
goabhigogoabhigo 

Email to User and Manager when Manager is changed

I have a Hierarchy (a lookup to User) field in User - it is called Mentor. The requirement is simple, when I change the Mentor, an email should be sent to new Mentor and the User.

I have created email field, populated the same using workflow. Then I created an email alert, to send the email to user's email and this newly created email field.

Output is surprising - The email is directed to Mentor and mentor user's mentor is shown!!
To make is clear here is the example:
Keir is the Mentor of Abhilash. The admin changes the mentor, to Bob. Now ideally Bob and Abhilash should get an email about this change. But what happens is Bob gets email as below:

Dear Bob,
Your mentor has been changed/mentee has been assigned. 
Mentor: Buzzard 
Mentee: Bob 


Is there any way to do this without writing apex trigger?

--
Abhilash.
Best Answer chosen by goabhigo
goabhigogoabhigo
Ok.. After whole lot of search found out the very basic meaning of various merge fields available in email template.

Please go through this article (https://help.salesforce.com/apex/HTViewHelpDoc?id=merge_fields_email_templates.htm&language=en) for your reference. Highlighting the one which solved:
 
To use merge fields from user records in email templates, select from the following merge field types:

User Fields — Use these merge fields to represent the sending user. Merge fields named {!User.field_name} return values from the user record of the person who created or updated the record that triggered the workflow rule.

Workflow Target User Fields — Use these merge fields only in email templates for workflow rules on the User object. Merge fields named {!Target_User.field_name} return values from the user record that was created or updated to trigger the workflow rule.

So, I had used {!User.Name}, instead I had to use {!Target_User.Name}.
User-added image

Trust someone who comes across this issue will get help from this.

--
Abhilash

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
Check which email is getting populated in email field. I guess its the email of the new mentor which is getting populated.
goabhigogoabhigo
Ok.. After whole lot of search found out the very basic meaning of various merge fields available in email template.

Please go through this article (https://help.salesforce.com/apex/HTViewHelpDoc?id=merge_fields_email_templates.htm&language=en) for your reference. Highlighting the one which solved:
 
To use merge fields from user records in email templates, select from the following merge field types:

User Fields — Use these merge fields to represent the sending user. Merge fields named {!User.field_name} return values from the user record of the person who created or updated the record that triggered the workflow rule.

Workflow Target User Fields — Use these merge fields only in email templates for workflow rules on the User object. Merge fields named {!Target_User.field_name} return values from the user record that was created or updated to trigger the workflow rule.

So, I had used {!User.Name}, instead I had to use {!Target_User.Name}.
User-added image

Trust someone who comes across this issue will get help from this.

--
Abhilash
This was selected as the best answer