We frequently use WhatId and WhoId attributes of Event and Task object.
According to Salesforce documentation those are:
The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object. The label is Related To ID.
The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID. The label is Name ID.
If Shared Activities is enabled, the value of this field is the ID of the related lead or primary contact. If you add, update, or remove the WhoId field, you might encounter problems with triggers, workflows, and data validation rules that are associated with the record. The label is Name ID.
Sometimes, we need to find out actual object reference instead of generic WhatId or WhoIdTo display the Actual Object Name instead of
WhatId
use thisWhatId Object is: <apex:outputLabel>{!Event.What.Type}</apex:outputLabel>
It will display like this:
Similarly, to find the Object name of
WhoId
use this:WhoId Object is: <apex:outputLabel>{!Event.Who.Type}</apex:outputLabel>
Similarly, to find the name of Object from Id in Apex use this code:
Pass WhatId or WhoId which you are retrieving from this SOQL query into that method.
Event eventRec = [SELECT WhatId, WhoId FROM Event Where Id = '00U9000001NgqWF'];
public static String getSobjectNameById(Id inputId) { Schema.SObjectType sobjectType = inputId.getSObjectType(); return sobjectType.getDescribe().getName(); }
Nice article Thanks for sharing this article Wonderful information from this website Thanks !!!
ReplyDeleteEmbedded training in chennai | Embedded training centre in chennai | PLC Training institute in chennai
Really great post It was so lovely to meet you, can't wait to catch up again
ReplyDeletefor your blog.
Apple iPhone Service Center in Chennai Anna Nagar
Really great post It was so lovely to meet you, can't wait to catch up again
ReplyDeletefor your blog.
Apple iPhone Service Center in Chennai Anna Nagar
This comment has been removed by the author.
ReplyDeleteVery informative post.Thanks Santanu.
ReplyDeleteNice tutorial blockchain developer course
ReplyDeleteThis comment has been removed by the author.
ReplyDelete