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
nimbusprojectnimbusproject 

Refining a ListView Set on a standard SOQL Query WITHOUT using ApexPage.StandardSetController

I need to review the results from a SOQL query by ListView on a set of avalible ListViews for an SObject that are returned from SOQL Query.

 

I can't seem to think of how to do this without using the StandardSetController.getListViewOptions() operation and the StandardSetController.getRecords() operation.

 

Thoughts?

 

Jordan


Or to put it another way: Pass the current listview context to the controller for a visualforce page so we can refine the records --

SteveBowerSteveBower

I'm not 100% sure I understand, but it seems as if you want to take the records defined from an existing listview (perhaps all records where "color=red"), and bring those records into your controller in such a way that you can further refine the list of records.

 

Not pretty, but can you use getListViewOptions(), choose a filter, set the filter.  then you can re-query against those id's with further criteria:

 

List<sobject__c> mySObjectList = [select id, myfields from sobject__c where size='XXL' and id in :myStandardSetController.getRecords();

 

Or perhaps I'm not understanding what you're trying to do?  Best, Steve.

 

nimbusprojectnimbusproject

Hi Steve,

 

Thanks! Actually you were pretty much on the money.

 

The issue really is, in our expirence .GetRecords() operation is a bug in Spring '11 (when accessed via webservices api, we've reported this to SF and they're checking on it), so I was trying to think of a work-around that would avoid .getRecords(), while still getting records organized by listview, witout using .GetListViewOptions() (which isn't broken, but still relys on .GetRecords() operation via the StandardSetController)

 

For now, because the operation still works when you don't use the Webservices API to access a controller that uses it.

 

Any other thoughts please let me know.

 

SteveBowerSteveBower

So, in your webservice class you instantiate a standardSetController, get the list of Filters, choose one and set it for the controller, then do getRecords.   And, if you call that class via the API (as opposed to a different VF controller for example) then the getRecords() call fails in some way?   How does it fail?   Very weird. 

 

I'd say that the obvious workaround is to just hard code the query into your webservice class.  However, your goal must be to externalize part of the query definition to the user in the form of the ListView definition.    Perhaps there is some other way you can do that?   For example you could write a VF page to gather query criteria from the user and store them in a string somewhere.  Then pull that string into your code and build a dynamic query with the user-defined criteria as well as your own?   Big ugly hack.

 

Nothing pretty leaps to mind.  Best, Steve.

nimbusprojectnimbusproject

Hi Steve-

 

Yes, it's been a complete mystery to us, because it's only in Spring '11, here's my original post, on the issue: http://boards.developerforce.com/t5/Visualforce-Development/Spring-11-No-Visualforce-context-has-been-established-SOAP/td-p/243399

 

Given we're waiting for Salesforce Tier 3 to investigate the issue, and we're pretty reliant on a robust 'ListView' integration, we're going to have to step around the webservice implementation for now.

 

Thanks for the advice, I'll keep it in mind.