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
Glenn at MvistaGlenn at Mvista 

Custom Object Display, with search boxes to limit data

I am trying to build a publicly accessible web page from a custom object and allow the user to select a subset of data.  For example, one field is a picklist in Salesforce and I want them to be able to show only those items that have a certain value selected.  I have created a page that shows the list of items, but I have no idea where to start to create the search form to filter that data.  Can anyone help me get started?

 

Here is the page I want to move to Visualforce - it is currently a PHP-based page built using the API - http://www.mvista.com/boards.php.

Best Answer chosen by Admin (Salesforce Developers) 
Saurabh DhobleSaurabh Dhoble

The error is in this line :

 

String qry = 'Select Id, Name from Lead where name like \'%'+searchText+'%\') Order By Name';

There's an extra bracket after searchText. It should be --

 

String qry = 'Select Id, Name from Lead where name like \'%'+searchText+'%\' Order By Name';

 

All Answers

Saurabh DhobleSaurabh Dhoble

If you are trying to build a search filter, there is no out of the box way to do it. You will have to construct a search textbox, and render the results in a data table.

Look at this post to get started with that :- http://boards.developerforce.com/t5/Visualforce-Development/how-to-add-search-button-in-visual-force-page/m-p/506591#M56298

 

Let me know if this helps.

 

Glenn at MvistaGlenn at Mvista

Thanks, that is exactly the pointer I was looking for to get started.

Glenn at MvistaGlenn at Mvista

Hi Saurabh,

 

To start I did a straight copy of your solution (I know it was not tested so was going to debug that first).  I am getting this message when I submit the search

 

unexpected token: )Error is in expression '{!search}' in component <apex:page> in page

 

I am not sure why, as the custom search method is defined in the class.  Do you have an idea as to that the cause could be?

Saurabh DhobleSaurabh Dhoble

The error is in this line :

 

String qry = 'Select Id, Name from Lead where name like \'%'+searchText+'%\') Order By Name';

There's an extra bracket after searchText. It should be --

 

String qry = 'Select Id, Name from Lead where name like \'%'+searchText+'%\' Order By Name';

 

This was selected as the best answer
Glenn at MvistaGlenn at Mvista

Thanks, that was the issue.  I am good to go now, I appreciate your help.