Difference between WhoId and WhatId

Its important to understand what is the difference between WhoId and WhatId, where they are being used.

What is the “difference between WhoId and WhatId?” is the most obvious question when you start working on activities for first time. It sounds confusing what exactly it refers to.

If you try to create an event or task from UI, you can see two fields.

Difference between WhoId and WhatId
Task Layout
  • Name : Here you can either choose Lead or Contact. It refers to people.
  • Related to : All Standard/Custom objects except Lead and Contact. It refers to objectives.

Lets take an example, Sales Rep “Rob” wants to Schedule a follow up with Contact “Mark” regarding his Opportunity which is yet to be closed. In this scenario, this information should be mapped as follows:

  • Assigned To : Sales Rep “Rob” who is scheduling meeting.
  • Name : Contact “Mark”.
  • Related To : Opportunity related to contact “Mark”.

What are the difference between WhoId and WhatID?

WhoId is API name of Name fields and WhatId is API name of Related To field. If you want to fetch task information, you need to use following SOQL:

SELECT Id, WhoId, WhatId, Subject from Task

These field are polymorphic in nature.

What is a polymorphic field?

A polymorphic field is one where the record can linked with multiple other types of objects. E.g: WhoID can only be linked with Contact or Lead records. WhatID can linked to all other objects excluding Contact and Leads. You cannot create such kind of fields in any if the Standard/Custom object.