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
Alexander HadjiiordanovAlexander Hadjiiordanov 

How to get list of leads lists?

Hi All,

How to get the list of all leads lists?
User-added image

Also how can i get the people from a particular list?

Thanks,
Alex
Best Answer chosen by Alexander Hadjiiordanov
Alain CabonAlain Cabon
Is there similar simple way to get all the leads from particular list ?
ApexPages.StandardSetController leadsController = new ApexPages.StandardSetController(Database.getQueryLocator([select Id, Name from Lead limit 1]));
leadsController.setFilterID('00B0O000009S4eQUAS');
system.debug(leadsController.getRecords());
List<Lead> mylist = (List<Lead>) leadsController.getRecords();
for (Lead mylead:mylist) {
    system.debug(mylead.id + '=' + mylead.name);
}
Alain

All Answers

Dushyant SonwarDushyant Sonwar
Hi Alexander ,

Currently The Answer for your above question is no. this is not possible in lightning experience .
https://salesforce.stackexchange.com/questions/124447/default-listviews-in-lightning

There is an idea on ideaexchange . You can upvote for it.
https://success.salesforce.com/ideaView?id=0873A000000cM0fQAE

Hope this helps
 
Alexander HadjiiordanovAlexander Hadjiiordanov
Hi Dushyant,
I don't want to change default view i want to get them in apex so i can use them on different place:


User-added image
Alain CabonAlain Cabon
Hi Alexander,

Could you try in the developer console?
 
ApexPages.StandardSetController leadsController = new ApexPages.StandardSetController(Database.getQueryLocator([select Id, Name from Lead limit 1]));
SelectOption[] myoptions = leadsController.getListViewOptions();
for (SelectOption myopt:myoptions) {
    system.debug(myopt.getvalue() + '=' + myopt.getLabel());
}

Anonymous Console: CTRL + E

Alain
Alexander HadjiiordanovAlexander Hadjiiordanov
Yes Alain,
It is working perfectly:

User-added image

Thank you so much. Is there similar simple way to get all the leads from particular list - for example "00B0O000009S4eQUAS = test list"?

Thanks again :)
Alex
Alain CabonAlain Cabon
Is there similar simple way to get all the leads from particular list ?

Could you try this?
ApexPages.StandardSetController leadsController = new ApexPages.StandardSetController(Database.getQueryLocator([select Id, Name from Lead limit 1]));
SelectOption[] myoptions = leadsController.getListViewOptions();
Id myfilterid = null;
for (SelectOption myopt:myoptions) {
    system.debug(myopt.getvalue() + '=' + myopt.getLabel());
    if (myopt.getLabel() == 'test list') myfilterid = myopt.getvalue();
}

leadsController.setFilterID(myfilterid);
system.debug(leadsController.getRecords());  // json result 1

leadsController.setFilterID('00B0O000009S4eQUAS');
system.debug(leadsController.getRecords()); // json result 2

Alain
Alain CabonAlain Cabon
Is there similar simple way to get all the leads from particular list ?
ApexPages.StandardSetController leadsController = new ApexPages.StandardSetController(Database.getQueryLocator([select Id, Name from Lead limit 1]));
leadsController.setFilterID('00B0O000009S4eQUAS');
system.debug(leadsController.getRecords());
List<Lead> mylist = (List<Lead>) leadsController.getRecords();
for (Lead mylead:mylist) {
    system.debug(mylead.id + '=' + mylead.name);
}
Alain
This was selected as the best answer
Alexander HadjiiordanovAlexander Hadjiiordanov
You are the best, Alain !!!!!!
I wish i know you offline so i could drown you in beer :)