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
ishwar panjari 10ishwar panjari 10 

Not able to check record is exist or not in standard set controller

I have to check that the record exist in view List or not. So for this i wrote the following code for checking that records exist in list view or not.

List<sObject> sobjectList=[select Name,Id from TestObj where Id='a0gG000000B8W2HIAV']; 
String query = 'Select Name from TestObj LIMIT 1'; 
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(Database.getQueryLocator(query)); 
List<System.Selectoption> ListViewList=ssc.getListViewOptions(); 
set<SObject> testset=new set<SObject>(); 
List<sObject> listChildObject=null; 
for (System.Selectoption selopn : ssc.getListViewOptions()){ 
    string viewid,viewlabel; 
    viewid=selopn.getValue();
    viewlabel=selopn.getlabel(); 
    ssc.setSelected(sobjectList); 
    ssc.setFilterId(viewid); 
    testset.addAll((List<sObject>)ssc.getSelected()); 

System.debug('testset-'+testset);

This above code is returning the testset is empty. Event this record exist in the list view of this user. But if i change the sequence like following:
ssc.setFilterId(viewid);
ssc.setSelected(sobjectList);
Now it will set records in each list view even though that records is not exist for this list view.
Actually i want to check that specific records exist in list view or not. I do not know which is best way to do in salesforce without iterating all records and checking.
Harpreet On CloudHarpreet On Cloud
@Ishwar, I could not understand your problem completely. But just see if this helps you -- http://salesforce.stackexchange.com/questions/64004/list-view-visibility

If it does not help, can you please be little more selective in your problem.
Matthew CokeMatthew Coke
I am working on a package for this. will have it out shortly