You need to sign in to do that
Don't have an account?
Change a select through a controller?
I have a request to create a mechanism that allows users of our knowledge base (using SalesForce knowledge) to automatically filter their selection based on URL. Was hoping to post here and get some advice.
The current functionality is as follows:
1. User goes to KB
2. User chooses product from select
3. Search filters based on select using controller / ajax
Desired Functionality:
User can go to KB in the traditional way and search normally OR:
1. User goes to kb.com/?product=MYPRODUCT
2. Controller gets the product variable
3. VisualForce sets the select to the chosen product based on the URL
What I've done:
1. Controller takes the product variable as a string
What I need to know how to do:
I'd like, somehow, to change the select based on the variable in my controller.
This has to be something simple. Any ideas?
Use a "binding" in your page's query. For example, your controller might look like this:
The magic here is the ":searchTerm" in the query. This automatically binds the value in searchTerm into the query. It automatically escapes SOQL characters that could be used for SOQL injection. You could also add a "%" and use the LIKE operator instead of "=". Also, if searchTerm was bound to an apex:selectList, it would automatically update the list value to the selected term. You could also validate the input against available options and blank out the value if it is not a legal value.