Ok, so I want to have a report that does not require the end user to know all about writing and customizing reports or memorizing field values. I ultimately want the user to be able to use a collection of prepopulated SelectList based filters on an apex page I've created to filter their report.
So far I have this as far as being able to filter by one value for each field:
- Create an Account report
- Add a filter for BillingState Equals blank (This is filter #1, or index 0)
- Create a Page with a SelectList and use a Controller to populate it with a list of States
- Create a CommandButton on the page and use a PageReference object to redirect to the Report
- At the end of the URL for the report, add pv0 (parameter value for index 0) = [selected state]
So this is all well and good – instead of having the user memorize valid field values and mess with report filters they can point and click stuff – so simple a sales person could do it.
But now I want to filter by a list of states (or some other text field). I can easily get a String[] list of states with the multiselect attribute of the SelectList, but I don't know how to go about applying it to the report. In an SQL sense I want add a "State=x OR State=y OR State=Z" or "State IN (x, y, z)" where condition to the reports query.
How could I go about doing this – filtering a report by a list of valid values for a field, and doing it programmably from a controller?
-
Is there some method to programmably create a temporary report on the fly? Clone a "template" report and then add OR filters as needed?
-
Is there a way to pass a set of objects to a report? Some reports return a lot of results, so this seems dangerous.
-
When doing PageReference redirection the Redirect attribute states that when it is false all the state information is retained, but the destination page must have the same controller – is there a way to use controllers with reports to customize their logic?
Best Answer
If I get you right, you're almost there.
Add your criteria values comma separated to the appropriate URL parameter. In your example, the pv0 URL parameter: