Print this page

How can I update a lead record based on activity of that record?

Knowledge Article Number 000228451
Description Can lead record be updated based on Task created on lead?

Yes it is possible to update any record based on the task created. By default in process builder you can update account or records related to the account on which the task is created.

But for standard objects like lead or any custom object there is no option to choose those records. Hence we have to use a combination of process builder and headless flow to achieve this.

This is done by using the first three character of any object record. Example any lead record starts with 00Q. So we will use these 3 characters to identify which object's record the task is related to and based on that record ID update the particular record by passing the value to headless flow.

As for lead and contact it is always chosen in the 'Name' field of the task. This name field's API name is 'who'

But for other objects it is the 'Related To' field of the task. This field's API name is 'what'.

So depending on the object of your choice this solution can be customized to update based on whoid or whatid.

This is given in detail in this article for a lead record
Resolution In the following use case, we are updating a picklist field called “Rating” on the lead record with the value HOT, when any task associated to the lead is completed. 

In Account, opportunity and contact the record can be directly chosen in the process builder itself however in lead it is not possible. Hence we have to use a combination of Process and Flow to achieve this

Create a simple Flow to update lead record. Let us call it PB to Flow

Click Path: Your name (Top right) | Setup | Create | Workflow & Approvals | Flows

1. Click on 'New Flow' button
2. Choose the element record update
3. Name it as "Lead Update Flow" or something of your choice
Update Lead ID equals Choose Create Variable
1. Name the variable as Lead ID in the unique name
2. Description - Fill something of your choice to make it easy to understand for future reference
3. Data Type Text
4. Input/output Type equals "Input and Output"
5. Leave Default Value as is
So you will get something like ID equals {!LeadID}
6. Field >> Rating with value >> HOT
Set this flow as the starting element (There will be Green downward arrow on top right of the element when you hover the mouse pointer. Clicking that arrow will set it as starting element ) >> Save (you can ignore the warning message) and activate the flow
Creating process using Process builder

Click Path: Your name (Top right) | Setup | Create | Workflow & Approvals | Process builder
Click 'New' button on top right

1. Create a New Process. Choose Task object
2. In the decision element enter the following details
Criteria Name >> Task assigned to Lead (anything meaningful is fine)
Criteria for executing actions
Conditions are met
1st Condition
Field >> [Task].WhoID  
Operator >> Starts with
Type >> ID
Value >> 00Q
WhoID starting with 00Q means the task is related to Lead records
2nd Condition
Field >> [Task].Status
Operator >> equals
Type >> Picklist
Value >> Completed
The task Object chosen in process builder and the decision element with both the above conditions imply that process will run on task that are related to lead and having status as completed

Next is launching flow

1. In the immediate action choose “Flow”
2. Choose the flow “PB_To_Flow” that we created initially
3. Field is Lead ID and reference is [Task].WhoID
This process will pass the particular Lead ID to which has completed task
The flow picks up the Lead ID and updates the field Rating as “Hot”


This article can help you to update the Lead record when we click on Log a Call in the activity history section. It won't update the Lead record if we click on Send an email button.

promote demote