Find your content:

Search form

You are here

email alert in workflow - sender's name in salutation in sent mail instead of recipient

 
Share

I have setup a custome object (Test WF) with default "Owner" and custom "Status" field. My aim is to trigger mail whenever "status" field is "Assigned", hence setup workflow rule with rule "Test WF: Status equals Assigned" and included email alert in immediate action on workflow. Below is the visualforce email template I am using.

<messaging:emailTemplate subject="WF EMail Test" recipientType="User" relatedToType="Test_WF__c">
<messaging:plainTextEmailBody >
Dear {!recipient.Name},

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Now if a user "Person 1" is creating the "Test WF" record, owner will be set to "Person 1". After this if "Person 2" will change the status field to "Assigned", an email will be triggered to "Person 1" like below.

Dear Person 2,

"Person 1" is getting this email containing text "Dear Person 2". Please note "to" and "from" email addresses are correct. I am facing issue here, why I am getting "Person 2" in the solutation even though it is sent to "Person 1" from "Person 2"?


Attribution to: Cool Boy

Possible Suggestion/Solution #1

Set the recipient to record owner while creating the email alert.

Email Alert - Set to Record Owner


Attribution to: Roshan

Possible Suggestion/Solution #2

I'm not totally sure why the recipient is not taking the owner field from the record. I set up a scenario where I have the following:

Selected Recipients

My Custom Object Owner

Then took the following actions

  1. As User 1 set the owner to User 2 and saved record.
  2. As User 1 change the status to Assigned and saved record
  3. Received email with recipient.Name set to User 1 even though the record owner was User 2.

Perhaps I'm misunderstanding something about the usage of Owner in this scenario, but it isn't obvious to me. I expected the recipient.Name to come from the owner field.

You can get around it by using the relatedTo merge field.

<messaging:emailTemplate subject="Status of My Custom Object Changed" recipientType="User" relatedToType="My_Custom_Object__c">
<messaging:plainTextEmailBody >
Recipient Fields:
recipient.Name: {!recipient.Name},
recipient.FirstName: {!recipient.FirstName} 
recipient.LastName: {!recipient.LastName}

RelatedTo Fields:
relatedTo.Owner.Name: {!relatedTo.Owner.Name}
relatedTo.Owner.FirstName: {!relatedTo.Owner.FirstName}
relatedTo.Owner.LastName: {!relatedTo.Owner.LastName}

</messaging:plainTextEmailBody>
</messaging:emailTemplate>

Attribution to: Peter Knolle

Possible Suggestion/Solution #3

This is actually an existing, known issue. The link provides a potential workaround:

Workaround
Use {!relatedTo.<relationship_name>.name}


Attribution to: Rooster
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1439

My Block Status

My Block Content