Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
WhoId and WhatId on Task Salesforce

WhoId and WhatId on Task Salesforce

May 17th, 2019

WhoId and WhatId on Task Salesforce

Are you finding out the meaning of WhoId and WhatId? Then, finally, you are at the right place for the detailed understanding of these two concepts. Because the perfect answer with example is nowhere else. First, let us understand the concept of WhoId and WhatId?

Concept of WhoId and WhatId

WhoId is the term used in Salesforce for pointing out the things of people. so basically it would be a contact id or leading id. This shows the role of the human via his/her contact or lead. WhoId is polymorphic in nature which generally says that the WhoId is similar to the Id of contact or lead with its name or label as ‘Name’.
WhatId is the term used in Salesforce for pointing out the type of things or objects. So, basically, it can be the Id of account and opportunity. This does not show related to human things like opportunities, cases, objects, campaign or accounts. WhatIds are also polymorphic in nature which simply shows that it is similar to the Id of some objects or things with the label of  ‘relation’.
We sometimes use attributes of WhatId and WhoId related to events and task objects. As per the documentation of salesforce these two are just
what is the representation of objects or things like campaigns, cases, etc. which are polymorphic and is similar to the related things’ Id.
WhoId is the representation of the human being like contact or role which is also polymorphic and is similar to the Id of contact or lead role.
If their shared activities are allowed, then the value in this field will be the lead or contact Id. And if you edit, add, or delete the field of WhoId, then you can have the issues in the workflows, validation rules of data, and triggers which are in association with the records with their name of the label ‘Name Id’.
So sometimes, we are required to determine the actual reference of objects without any use of generic WhoId and WhatId.
For displaying the name of the real object without the use of WhatId, then use below code
WhatId object is : <apen:outputlabel>{!Event.What.Type}</apex:outputLabel>

It will show something like below

WhatId Object is: Account
In the same way, for determining the name of an object then type the following
WhoId Object is: <apex:outputLabel>{!Event.Eho.Type}</apex:outputLabel>

Then it will show something like below

WhoID Object is: Contact
WhatID Object is: Opportunity
Now let us see one instance where you will create the activity history of the contact event. This is very easy as adding the field Name with the name of the contact. And this is offered by salesforce from so early days. You can also add those name of invitees and contacts or leads to the event just by navigation link at the bottom page.
But then you will also see the limitations where no other contacts you have added, have the event on the history of activities.
This is just an easy example of both concepts. Salesforce also introduced the new characteristics for overcoming this disadvantage which is shared activities and so many numbers of contact on one activity. Shared activities enable you to search or select the number of contacts at on time.
And after selecting them, the Name field will show you one of the names of the contact list and then another five if you choose six contact names in total. Also, you will find out the event history list of activities of all the contact you have chosen.
Thus, this article clears you with the concept of both WhatId and WhoId with a proper and easy example. Sometimes, it creates the confusion in understand WhoId which is on the object of the event. Suppose if we are connecting the contact and wish to make a point where you can associate a lead, then the ‘related to’ or the ‘WhatIddisappears. Salesforce does not enable you to auto-fill the field if the lead is connected in the Name field of label. Thus, the event is created in such case and WhatId is blank.
Thus, here we understood the simple and clear meaning and use of both the concepts of WhoId and WhatId.