The Task Reminder Email in Salesforce: How to Pass the Client or Lead information
Recently, we got a request to extend the task reminder email template to include the information about the related Lead or Contact to the created task.
The task reminder's email in Salesforce
The Who ID column on the Task/Activity object is the polymorphic field, which means that it can be related to more than one object type (in this case it is a Lead or the Contact).
In the email template, there is a possibility to set WhoId as a placeholder - but that does not make any sense.
Salesforce has made its platform based on the ideas which help shape the Salesforce product. There are a lot of ideas Salesforce specialists come up with every day which makes Salesforce even more popular. (https://trailblazer.salesforce.com/ideaSearch).
Sometimes your idea doesn’t have high priority like other ideas, and you should go for the workaround.
One of the ideas we saw was “Email template on task does not show names for whatId and whoId”. Since there is no out-of-the-box solution for this problem, we’ve decided to find a workaround.
How to pass the client or lead information to the task-reminded email?
The requirement is that we have to show the Full Lead Name or Contact Full Name.
To do that, even on the Salesforce Essential, we created the Flow called: Task’s Contact/Lead Info Set By Who ID.
To store the necessary info, we extended the Task object with an additional hidden text field called ContactLeadInfo. This flow will update this field on the Who ID value.
Once we have populated additional hidden field, we can use it in the email template:
The task Reminder's Email in Salesforce Classic Email Template
The flow diagram for populating the Lead/Contact information in Salesforce
Flow diagram example for populating the Contact information in Salesforce
Let’s explain the flow in more detail.
The created flow is of the following type: Record-Triggered Flow where trigger should occur when creating or updating an existing record of Task type.
Since the task can be created on the Tasks page, the Who ID column will not be populated.
Because of that, we have to check if the Who ID value is populated (Is Contact/Lead exist).
Once we check that, the next step is to try to get the Contact record based on the Who ID.
If that record exists, we use the option “Update Records” which should update the Hidden Field (ContactLeadInfo) with Contact’s Full Name. Otherwise, we will try to get the Lead record based on the Who ID value. If the record exists, the next step would be to update the hidden field as we did for Contact object.
Conclusion
It is worth mentioning that the best practice is to use the Process Builder instead of Flow whenever it is possible. Since we cannot get the record via Process Builder, we picked the Flow as a solution.
Salesforce has practical tools - and we can accomplish amazing things even without coding.