Understanding WhatId and WhoId in Salesforce

Salesforce as a robust customer relationship management (CRM) platform, offers a wealth of tools and features to streamline sales and customer service activities. One of the key features that enhance its functionality is the ability to log and manage activities such as tasks and events. But to fully unlock the power of Salesforce’s Activity management, it’s essential to understand how WhatId and WhoId fields work.

In this blog post, we will explore WhatId and WhoId in Salesforce, their differences, use cases, and how they can help your organization better track interactions with customers, prospects, and leads. 

What Are WhatId and WhoId?

In Salesforce, WhatId and WhoId are fields used in Activity records (such as Tasks and Events) to relate those activities to other records in Salesforce. These fields help you associate activities with business records (the “What”) and individuals (the “Who”).

WhatId: refers to the “Object or Record” that is the “What” in the relationship. This usually refers to non-person objects like Accounts, Opportunities, Cases, and other business-related entities.

WhoId: refers to the “Person or individual” related to the activity, typically pointing to Contact or Lead records.

Let’s dive deeper into each of these fields.

What is the WhatId?

The WhatId is used when you want to associate an activity with a business record, typically non-person objects in Salesforce. This field stores the ID of the record that represents the “thing” you’re interacting with in that activity.

What is the WhatId?

Examples of Objects Linked with WhatId:

  • Accounts: Linking an activity (e.g., a meeting) to a specific Account.
  • Opportunities: Associating an activity with a sales opportunity.
  • Cases: Connecting a support-related activity to a customer case.
  • Custom Objects: If your Salesforce instance has custom objects, the `WhatId` can link to those as well.

Use Case Example

Let’s say you have an Opportunity in Salesforce related to a potential sale. You create a Task to follow up with a prospect, and this task needs to be associated with the Opportunity. In this case, the `WhatId` will store the ID of the Opportunity record.

In this case:

  • The WhatId will store the Opportunity ID (i.e., the Opportunity record that represents the sale you’re working on).
  • The WhoId might be used to store the Contact or Lead you’re interacting with, such as the primary decision-maker at Grand Hotels Emergency Generators.
// Create a new Task
Task newTask = new Task();
newTask.Subject = 'Follow Up Opportunity';
newTask.Description = 'Review and update opportunity stages';
newTask.WhatId = '006xxxxxxxxxxxxxxx'; // ID of the Opportunity
newTask.Status = 'In Progress';
newTask.Priority = 'Normal';
insert newTask;

The Role of WhatId:

  • Link Activities to Business Records: WhatId helps track the relationship between an activity and a business-related entity, such as an Opportunity, Case, or Account.
  • Sales & Support Insights: By associating activities with records like Opportunities and Cases, it provides valuable insights into the progress of sales deals and customer service issues.

Learn about Working with Polymorphic Relationships in SOQL Queries.

What is WhoId?

The WhoId is used when you need to associate an activity with a person either a Contact or a Lead. It allows you to track interactions with individuals within your CRM system.

Examples of Objects Linked with WhoId

  • Contacts: Linking an activity to a person in your network, such as a customer or prospect.
  • Leads: Associating an activity with a potential customer who has not yet been converted to an Account or Contact.

Use Case Example: You are logging a Task to call a Contact named Grand Hotels Emergency Generators at Grand Hotels Emergency Generators to discuss a potential partnership. In this case, the WhoId will store the ID of the John Doe Contact record, while the WhatId might point to the Opportunity related to Grand Hotels Emergency Generators.

Task newTask = new Task();
newTask.Subject = 'Call with Client';
newTask.Description = 'Discuss project details and deadlines';
newTask.WhoId = '003xxxxxxxxxxxxxxx'; // ID of the Contact or Lead
newTask.Status = 'Not Started';
newTask.Priority = 'High';
insert newTask;

The Role of WhoId:

Track Person-Related Interactions: WhoId is essential when tracking activities that are tied to individuals, such as sales calls, emails, or meetings with contacts and leads.

Personalize Customer Interactions: Linking activities to people helps you maintain a personal touch with your customers and prospects, ensuring you don’t lose track of important interactions.

Example to Clarify

You have a Sales Opportunity  with Grand Hotels Emergency Generators. You log a Task  to follow up with John Doe, who is the Contact at Grand Hotels Emergency Generators.

Task newTask = new Task(
    Subject = 'Call with John Doe',
    WhoId = '0035g00000Dvl6e', // Contact ID for John Doe
    WhatId = '0065g00000T6rtz'  // Opportunity ID for Acme Corp Sale
);
insert newTask;
WhatId and WhoId in Salesforce

Conceptual entity groupings for “What” (activity object) and “Who” (activity participant), along with entities and relationships involved in managing tasks and events.

Source: https://architect.salesforce.com/diagrams/data-models/platform/tasks-events .

Summary

I hope this post help you to under the difference between whatid and whoid. How WhatId and WhoId in Salesforce work

Satyam parasa
Satyam parasa

Satyam Parasa is a Salesforce and Mobile application developer. Passionate about learning new technologies, he is the founder of Flutterant.com, where he shares his knowledge and insights.

Articles: 26

Leave a Reply

Your email address will not be published. Required fields are marked *