You need to sign in to do that
Don't have an account?
ishwar 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.
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.
If it does not help, can you please be little more selective in your problem.