function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
itstaff1.3920641347534116E12itstaff1.3920641347534116E12 

Recently View Object - Phone field not displaying

Hello,

I have a custom VF page in which I have a drop down field that displays the top 25 most recently viewed objects. Currently, it is only displaying the Name and Object Type:

var result = sforce.connection.query("SELECT Id, Name, Type FROM RecentlyViewed WHERE LastViewedDate >= "+fst+" AND Type IN ('Opportunity', 'Lead', 'Account', 'Contact') ORDER BY LastViewedDate DESC LIMIT 25"

However, we have scenarios where the names are the same between leads, therefore it is hard to make a distinction as to which lead was viewed. I would like to also include phone into the display, so that it is easier to make that distinction. I have tried adding phone to my query above, however, the results are showing as 'null' on the page.
I have made sure the lead record has a phone number populated in the 'Phone' field.

Any ideas about why the phone value is not getting populated?

Thanks.
William TranWilliam Tran
Unfortunately Phone, Title, Email, Alias. etc only apply to type of USER.

To get phone number for leads you need to query leads explicitly like:

SELECT Id, Name, Phone
FROM lead
WHERE LastViewedDate != NULL 
ORDER BY LastViewedDate DESC

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Thanks