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
- As User 1 set the owner to User 2 and saved record.
- As User 1 change the status to Assigned and saved record
- 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>
Preamble (altered to reflect comment trail)
With a rule NOT( ISNULL( Maintenance__c ) )
and workflow evaluation criteria of:
Evaluation Criteria : created, and any time it’s edited to subsequently meet criteria
The workflow rule only executes if the value of the field changes from null to nonNull or when the record is created.
The workflow will not evaluate at all if the Maintenance__c
changes from one non-null value to another non-null value as that won't "subsequently meet criteria" (true is still true). Note, for time-based workflows, the Every time it is edited
evaluation radio button is not available.
Once the time-based workflow is entered for the object, the object stays in that workflow until the time-based condition is no longer true (maintenance start date becomes null) or the time trigger finally happens (345 days after account.maintenance_start_date__c
). If the maintenance start date is changed on the Account, the time based trigger adjusts accordingly per the doc:
What happens if I update the value of a date field used in a time
trigger? If you update the date field used in a time trigger,
Salesforce recalculates the time trigger as long as the time trigger
has not yet fired and the recalculation does not reschedule the time
trigger to a date in the past.
For example, if a workflow rule alerts the opportunity owner seven
days before the opportunity close date and the close date is set to
2/20/2008, Salesforce sends the alert on 2/13/2008. If you update the
close date to 2/10/2008 and the current date is 2/2/2008 or before,
Salesforce reschedules the alert for 2/3/2008. The evaluation date of
pending actions is ALWAYS reevaluated and updated if necessary
irrespective of the rule criteria. Of course, if the rule is evaluated
to false, it does not matter as the actions are removed from the
queue.
If you were backdating to a date in the past, per the doc, the time trigger does not adjust
Best Answer
I think a regular WF won't be enough in your case because once you know the name of the user/person you need to query he's id to find he's email.
So I would do it with a process builder and a flow:
Go to Setup > Create > Workflow & Approvals > Process Builder:
Create a process on you're object that will be fired on creation of a record.
Create a step to check the value of the list:
First check if it's not blank. Now go to the 2nd step:
Go to Setup > Workflow & Approvals > Flows:
2.1 Create a flow.
2.2 Create a text variable with public input/output to receive the name form the process builder.
2.3 Create another variable with same props for the found email.
2.4 Drag a fast lookup operation to the pallet and mark it as the start point if the flow.
Inside the fast lookup: Search your user/contact by name. If found take the email of the found record and assign to your email flow-variable.
Now drag your email-notification to the flow pallet and assign the email var to it.
On saving, make it an automated flow (so it could be fired from the process builder).
Now return to your process builder:
3.1 On the step that checks the picklist:
3.2 Add an action to fire a flow.
3.3 Pick your newly created flow.
3.4 Assign the picklist value (the user/person name) to the flow's var.
3.5 Save the process.
3.6 Activate it.
And you're done!
You can find more instructions on process builder stuff in the Automated Champion blog.