Admins / Developers

What Is the Difference Between WhoId and WhatId?

By Jordyn Jaffer

Most Salesforce administrators have heard the terms “WhoId” and “WhatId” when working with the task or event object. For those not familiar with these terms, perhaps you have heard of the Salesforce field labels for them instead: “Name” and “Related To”.  

WhoID (Name) and WhatId (Related To) are the API names for these fields on the task and event objects. They are both considered to be polymorphic, meaning their ID value is equivalent to the ID value of a related object, but are different in other ways. In this article, we’ll learn the similarities and differences between these two fields!

WhoId

WhoId is the API name for the “Name” field on activity-related objects. Users should look to populate this field when they want the task to be related to a Lead or Contact record within Salesforce.  

I typically refer to this field as the one that references another human, when it comes to my task or event.  

When using Salesforce Events to track meetings with clients, your users will want to make sure that they populate this field with the lead or contact that they are meeting with. It’s possible to have multiple contacts and leads associated with an activity if you have Shared Activities enabled in your org. This feature will allow you to relate up to 50 contacts or leads to a non-recurring activity.

WhatId

WhatId is the API name for the “Related To” field on the activity-related objects. This field can be associated with many different objects including:

  • Accounts
  • Opportunities
  • Campaigns
  • Cases
  • Custom Objects

Here is a view of all of the standard objects that can be associated with the “Related To” field:

While the “Name” field is associated with humans, the “Related To” field can be associated with anything else within Salesforce.  

This field is not available when a user populates the “Name” field on the activity with a Lead instead of a contact. This is because the “Related To” field needs to be associated with an account and the lead object does not have a relationship with the account object.

There is also an account field on the task and objects that will be automatically populated, based on the information in the “Name” and “Related To” fields. If the WhoId field is populated with a contact record, the account field will look to automatically populate with the account Id associated with the contact. If the WhatId field is populated with an AccountId, the account field will be populated with the same AccountId.

The “Related To” field can be related to objects other than an account – although Salesforce still looks to determine which account is associated with the activity. If the WhatId is populated with the Id of an opportunity, contact, or other object that has a relationship with accounts, Salesforce will use that object’s AccountId for the activity account field.  

If the WhatId is populated to another object (now account) and the WhoId is populated to a contact, Salesforce will use the contact’s AccountId for the account field.

Summary

The WhoId and WhatId fields are similar as they are both populated by Ids of other records within your Salesforce environment. However, that is where the similarities end.  

WhoId is used for our “human” objects, contacts and leads, and is labelled as “Name” on the task and event objects.  

WhatId is used for multiple other objects that are not human-related and is labelled as “Related To” on the same objects.

The Author

Jordyn Jaffer

Jordyn Jaffer is a 9x Certified Salesforce Administrator and Marketing Champion with a specialization in Pardot.

Comments:

    Francesc
    July 27, 2022 3:26 pm
    good article to clarify the difference. However, I am still not able to understand what is the difference and concept between "Who id" (Name) and Attendees. Could you please clarify it? Also while using the Salesforce add-in in Outlook is it possible to link to "Attendees" instead of Whoid? thank you!
    Jordyn Jaffer
    August 03, 2022 2:27 pm
    Hello Francesc, Thank you for reaching out with your question! Attendees on the Event object is very similar to WhoId, but there is one difference - the Attendees field can include Users as well. Here's a help article on how. Event Attendees sync with features like the Outlook plug-in: https://help.salesforce.com/s/articleView?id=sf.lightning_sync_admin_event_attendee_sync.htm&type=5 Thanks, Jordyn Jaffer
    Gwenn Ferguson
    October 10, 2022 7:27 pm
    If I want to add the name of the owner (username) of the WhoId/WhatId record to a related Event/Task page layout, how would I do that? I've tried formula fields, lookup relationship and flow without success.
    Alice
    November 01, 2022 3:23 pm
    Quando uso o WhatId para atualizar um campo por flow, está me voltando o seguinte erro: INSUFFICIENT_ACCESS_OR_READONLY: insufficient access rights on object id. Como faço para este perfil de usuário ter acesso?
    Jordyn Jaffer
    November 04, 2022 12:11 am
    Hola Alice, Me disculpo si esto no tiene sentido ya que no hablo español y usé el traductor de Google para esto. Este error se debe a la configuración de uso compartido. Para superar este problema, consulte lo siguiente 1. Valores predeterminados, reglas de colaboración y jerarquía de roles de toda la organización del objeto en el que intenta actualizar el registro. 2. Titular del registro que se intenta actualizar. 3. Verifique la lógica de activación y verifique la configuración predeterminada de toda la organización, las reglas de colaboración y la jerarquía de roles de los registros de objetos relacionados que se están actualizando.
    Jordyn Jaffer
    November 04, 2022 1:18 am
    Hi Gwenn, This is not possible using standard Salesforce custom fields as the WhoId/WhatId fields can reference many different objects. The only idea that I have would be creating a custom text field called something like "Related Record Owner" and then populating that via Flow. You can run the Flow on Task/Event Creation, but then you'll have to make decision branches for each possible object that your company could use to populate those fields to determine which object you need to pull the Owner value from. An easy way to do this is create a formula field within the Flow that looks at the first 3 characters of the record Id and determines the object its associated with). For that you can use the following article to help determine the object; https://sfdcscout.com/2020/06/10/how-to-know-salesforce-object-type-from-the-record-id/. Then, you can use a Get Records on that object (so set it up for all objects) to get the Owner Name of that object and then assign that value to your custom text field. Finally, you would update the triggering Task/Event record to finish the Flow. Let me know if you want to talk this out more together! Happy to help!
    sohini
    June 14, 2023 5:38 am
    Can we use the WahtId for cross object reference formula? Like if an opportunity is selecte din the "related to" field, can be show other fields related to that opportunity by formula filed in the activity page?

Leave a Reply