3

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"?

3 Answers 3

1

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>
1
  • Thanks a lot Peter for your reply. In my scenario I do not want to change owner field. User 1 creates the record with status "Pending" (default), now User 2 change status to "Assigned". Now expectation is to trigger email to User 1 from User 2 with salutation like "Dear User 1" but user 1 is getting in mail "Dear User 2". Previously I also tried your solution of using relatedTo.Owner.Name but in case if owner is a queue like "Test WF Q", User 1 get mail like "Dear Test WF Q" instead of "Dear User 1" as User 1 is the queue member. I really need help on this, Thanks Again!
    – Cool Boy
    Commented Sep 15, 2012 at 6:19
0

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

Email Alert - Set to Record Owner

0
0

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .