You need to sign in to do that
Don't have an account?
Pritam Shekhawat
Dynamic Search - OnKeyUp / SOQL escapeSingleQuotes
hii,
I'm working on a project for a dynamic search of clients using Jeff Douglas's blog as a template
http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/
I have everything displayed correctly, but in controller am not able to retrive dynamic picklist value.
https://jeffdouglas-developer-edition.na5.force.com/examples/CustomerSearch
i used contact LeadSource Picklist Value in this controller.
Tell me how to retrive dynamic picklist value .its show Error: Compile Error: Invalid type: Schema.DescribeFieldResult at line 85 column 9
I'm working on a project for a dynamic search of clients using Jeff Douglas's blog as a template
http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/
I have everything displayed correctly, but in controller am not able to retrive dynamic picklist value.
https://jeffdouglas-developer-edition.na5.force.com/examples/CustomerSearch
i used contact LeadSource Picklist Value in this controller.
Tell me how to retrive dynamic picklist value .its show Error: Compile Error: Invalid type: Schema.DescribeFieldResult at line 85 column 9
public with sharing class ContactSearchController { // the soql without the order and limit private String soql {get;set;} // the collection of contacts to display public List<Contact> contacts {get;set;} // the current sort direction. defaults to asc public String sortDir { get { if (sortDir == null) { sortDir = 'asc'; } return sortDir; } set; } // the current field to sort by. defaults to last name public String sortField { get { if (sortField == null) {sortField = 'lastName'; } return sortField; } set; } // format the soql for display on the visualforce page public String debugSoql { get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; } set; } // init the controller and display some sample data when the page loads public ContactSearchController() { contacts= new List<Contact>(); soql = 'select FirstName, LastName,account.name,LeadSource FROM Contact Where account.Name!=null'; runQuery(); } // toggles the sorting of query from asc<-->desc public void toggleSort() { // simply toggle the direction sortDir = sortDir.equals('asc') ? 'desc' : 'asc'; // run the query again runQuery(); } // runs the actual query public void runQuery() { try { contacts = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'); } catch (Exception e) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!')); } } // runs the search with parameters passed via Javascript public PageReference runSearch() { String FirstName = Apexpages.currentPage().getParameters().get('FirstName'); String LastName = Apexpages.currentPage().getParameters().get('LastName'); String LeadSource = Apexpages.currentPage().getParameters().get('LeadSource '); String accountName= Apexpages.currentPage().getParameters().get('accountName'); soql = 'select FirstName,LastName,LeadSource,account.name FROM Contact Where account.Name!=null'; if (FirstName!= null && !FirstName.equals('')) soql += ' and FirstName LIKE \''+String.escapeSingleQuotes(FirstName)+'%\''; if (LastName!= null && !LastName.equals('')) soql += ' and LastName LIKE \''+String.escapeSingleQuotes(LastName)+'%\''; if (accountName!= null && !accountName.equals('')) soql += ' and account.Name LIKE \''+String.escapeSingleQuotes(accountName)+'%\''; if (LeadSource !=null && !LeadSource.equals('')) soql += ' and LeadSource LIKE \''+String.escapeSingleQuotes(LeadSource)+'%\''; // run the query again runQuery(); return null; } public List<String> LeadSource{ get { if (LeadSource== null) { LeadSource= new List<String>(); Schema.DescribeFieldResult field = Contact.LeadSource.getDescribe(); for (Schema.PicklistEntry b : field.getPicklistValues()) LeadSource.add(b.getLabel()); } return LeadSource; } set; } }
Finally i solveout my problem, actually there are some problem with my developer org. so its show compile error . I used another developer org its works finally :)
All Answers
--
May the Force.com be with you!
Finally i solveout my problem, actually there are some problem with my developer org. so its show compile error . I used another developer org its works finally :)