+ Start a Discussion
Stephane NachezStephane Nachez 

Retrieving contacts from a specific contact list view

Hi everybody,   I would like to know how to retrieve all the contacts from a specific contact list view from its id (by view i mean particular set of filtered contacts that we can create from the interface) . I've been looking for it for a long time but didn't find a way to do it.

Thank you very much
Best Answer chosen by Stephane Nachez
AmulAmul
Stephane,

In this regard you have to use listview API
http://andyinthecloud.com/2014/09/20/super-listview-viewer-using-winter15-listview-api/

hope this will help you much.

 

All Answers

AmulAmul
Hi stepahne,

Do you need to selected contact ids from the list view to process it further?

Are you looking to export them all? or you wanted to perform certian action on the selected list view contacts.?




 
sharathchandra thukkanisharathchandra thukkani
In this situtation it is better you go with the visual force page, If you still want to go with standard you need to use formula field which will store id of the record and you can use this field in the filter
Stephane NachezStephane Nachez
Hi , thank you for your replies.
No Amul, i would like to get the infos of all the contacts from a specific view, without needing to check their row..

something like "select * from contacts where  id in ( select contact_id from views_contacts where view_id =xxx ) "

(just to explain what i want to do.. but i don't find which relationship/fields  i should use to get it.

To explain a little better : My code should allow a user to select a view then press a button which will perform an action on all the contacts of this chosen view.

Thank you very much
AmulAmul
For this you have to create a new List Button on Contact.


See this blog:
http://abhithetechknight.blogspot.in/2013/09/concept-of-standardsetcontroller-for.html


Let me know if this can help.
 
Stephane NachezStephane Nachez
Thank you very much for your reply Amul. I already have a button. I've already found code which allows me to retrieve selected contacts from a list. It seems it's what do the code on your link too, because it uses getSelected()    . But how to do if i want all the contacts from the view ?

For example the user can create a view "male customers",   a view "female customers" or any other view he wants using filters. Then i need to be able to retrieve all the contacts from one of these views. Thank you.
AmulAmul
Stephane,

In this regard you have to use listview API
http://andyinthecloud.com/2014/09/20/super-listview-viewer-using-winter15-listview-api/

hope this will help you much.

 
This was selected as the best answer
Stephane NachezStephane Nachez
Thank you very much. You are super helpful. Salesforce is powerful but a real jungle when you are a newbie on it:)
AmulAmul
here is one more link that will give you more idea:
http://clicksandcode.blogspot.in/2014/10/export-records-from-list-view-listview.html