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 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.
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:
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.
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.
Jovica developed a talent for solving difficult problems by using a method called divergent thinking. One of his premises is that every day is unique, so you should fill it with positive energy and fun.