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

HELP displaying SOQL Results in Visualforce?

Hi -- I'm very new to Apex development so need to know if the following is possible, and if so, any tips for implementing.

I am trying to build a Visualforce page that displays the results of a pre-defined set of SOQL queries.  The queries are similar in structure to basic Opportunity reports, but rather than create reports, we want to display the results under a PageBlock or some other section / grouping, and display all results for our queries on one page.

The idea would be that the Visualforce page (let's just call it "apex/OppAnalysis") would be launched from a link on the Account record.  The link would push the Account ID/Account Name from the record it came from. The page would then do a search for all Opportunities that meet the query parameters and then display those Opportunities on the page under desired sections.

The idea would be for the Visualforce page to be populated with a particular Account Name / Account ID  and then displaying the Opportunities related to that Account on the page.  Obviously, we don't want ALL Opportunities, just those that meet a specific list of criteria like "Opportunities Created Last 30 Days", "Won Opportunities for Current Fiscal Year", etc.

The question is: How do I get the SOQL results to display on the screen?  Ideally, we'd like to have them show up in a list format, in a table, or perhaps as links that the user can click on to get more information.  However, I'm unsure if this is possible and if so, what functionality I need to leverage to get this done.

Thanks for any ideas.
I recommend starting by reading the "Introduction" section of the Visualforce developer guide. It walks you through some simple tutorials that will illustrate many of the concepts you will need to apply in your scenario. There is a specific sample on building a table.

Thanks for your reply.

I have spent a lot of time in the Visualforce tutorials, and they've been pretty helpful in helping me get up to speed.  However, I didn't find anything on displaying a table of data that only meet certain criteria.  The tutorials cover how to display the related Contacts of an Account (for example) with the desired column headings (which is cool), but really only replicates the standard functionality in SFDC, and doesn't allow for creation of a "filter" on those related objects.  (such as "Only show me contacts with 'VP' in the title"). 

So far I've also looked at the Apex language reference, which gives some insight into writing SOQL/SOSL queries, since this is what I think I'll need to do to build a list/arry of Opportunities.  The challenge for me is finding out how to display that information to the user after the list is generated.