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
maheshep.ax379maheshep.ax379 

How can i access conact list?

i want to access view my contacts from the standard object contacts.
is there any soql qurey to do this???

thanks in advance.
soofsoof

A little clarification: Do you want to retrieve a list of Contacts that apper in Contact View named "My Contacts"?  Or do you want to describe the Contact View (named "My Contacts") itslef?

You can get a list of Contacts that appear in "My Contacts" view, using the following code:

Code:
List<Contact> contacts = [select Id, FirstName, LastName from Contact where OwnerId = :UserInfo.getUserId()];


This statement will return the Contacts that appear in the "My Contacts" view of the user, who executes the code.  If you want to retrieve the list of Contacts that appear in the "My Contacts" of a particular user, then replace UserInfo.getUserId() with the ID of that User.  Hope this helps!

 

mahesh.epmahesh.ep
thanks for a quick reply. sorry for the spelling mistake...
but my doubt is not that...
see... when we look at contacts tab we will have a view. if i created a new view can i access it through soql???
even if it is not possible also.. pls reply....

tmatthiesentmatthiesen
Views are not directly accessible in Apex -but you can emulate the view by creating a soql query with corresponding filters.