You need to sign in to do that
Don't have an account?
bingi crm 7
I am try to search record in vf page first name are qualification . But i am unable to view the record code is not error were exactly i am missing code
<apex:page controller="ContactSearchController1" sidebar="false">
<apex:form >
<apex:pageMessages id="errors" />
<apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="criteria">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("Contact").value,
document.getElementById("Speciality").value,
document.getElementById("Qualification ").value,
document.getElementById("MoblieNumber ").value,
);
}
</script>
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="Contact" value="" />
<apex:param name="Speciality" value="" />
<apex:param name="Qualification" value="" />
<apex:param name="MoblieNumber" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">Contact Area<br/>
<input type="text" id="Contact" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Speciality<br/>
<input type="text" id="Speciality" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Qualification<br/>
<input type="text" id="Qualification" onkeyup="doSearch();"/>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Doctor}" var="Doc">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Contact" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Contact" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Contact_Area__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Speciality " action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Speciality " assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Speciality__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Qualification" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Qualification" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Qualification__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
public class ContactSearchController1 {
// the soql without the order and limit
public String soql {get;set;}
// the collection of contacts to display
public List<Doctor__c> Doctor {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 = 'Speciality'; } 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 ContactSearchController1() {
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where 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 {
Doctor = 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 ContactArea = Apexpages.currentPage().getParameters().get('ContactArea');
String Speciality = Apexpages.currentPage().getParameters().get('Speciality');
String Qualification = Apexpages.currentPage().getParameters().get('Qualification');
String MoblieNumber = Apexpages.currentPage().getParameters().get('Moblie Number');
String Email = Apexpages.currentPage().getParameters().get('Email');
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where name != null';
if (!ContactArea.equals(''))
soql += ' and ContactAreaincludes (\''+ContactArea+'\')';
// if (!Contact_Area__c.equals(''))
// soql += ' and Contact_Area__c LIKE \''+String.escapeSingleQuotes(Contact)+'%\'';
if (!Speciality.equals(''))
soql += ' and Speciality LIKE \''+String.escapeSingleQuotes(Speciality)+'%\'';
if (!Qualification.equals(''))
soql += ' and Qualification LIKE \''+String.escapeSingleQuotes(Qualification)+'%\'';
if (!MoblieNumber.equals(''))
soql += ' and MoblieNumber includes (\''+MoblieNumber+'\')';
if (!Email.equals(''))
soql += ' and Email includes (\''+Email+'\')';
// run the query again
runQuery();
return null;
}
}
<apex:form >
<apex:pageMessages id="errors" />
<apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="criteria">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("Contact").value,
document.getElementById("Speciality").value,
document.getElementById("Qualification ").value,
document.getElementById("MoblieNumber ").value,
);
}
</script>
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="Contact" value="" />
<apex:param name="Speciality" value="" />
<apex:param name="Qualification" value="" />
<apex:param name="MoblieNumber" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">Contact Area<br/>
<input type="text" id="Contact" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Speciality<br/>
<input type="text" id="Speciality" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Qualification<br/>
<input type="text" id="Qualification" onkeyup="doSearch();"/>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Doctor}" var="Doc">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Contact" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Contact" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Contact_Area__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Speciality " action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Speciality " assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Speciality__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Qualification" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Qualification" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Qualification__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
public class ContactSearchController1 {
// the soql without the order and limit
public String soql {get;set;}
// the collection of contacts to display
public List<Doctor__c> Doctor {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 = 'Speciality'; } 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 ContactSearchController1() {
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where 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 {
Doctor = 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 ContactArea = Apexpages.currentPage().getParameters().get('ContactArea');
String Speciality = Apexpages.currentPage().getParameters().get('Speciality');
String Qualification = Apexpages.currentPage().getParameters().get('Qualification');
String MoblieNumber = Apexpages.currentPage().getParameters().get('Moblie Number');
String Email = Apexpages.currentPage().getParameters().get('Email');
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where name != null';
if (!ContactArea.equals(''))
soql += ' and ContactAreaincludes (\''+ContactArea+'\')';
// if (!Contact_Area__c.equals(''))
// soql += ' and Contact_Area__c LIKE \''+String.escapeSingleQuotes(Contact)+'%\'';
if (!Speciality.equals(''))
soql += ' and Speciality LIKE \''+String.escapeSingleQuotes(Speciality)+'%\'';
if (!Qualification.equals(''))
soql += ' and Qualification LIKE \''+String.escapeSingleQuotes(Qualification)+'%\'';
if (!MoblieNumber.equals(''))
soql += ' and MoblieNumber includes (\''+MoblieNumber+'\')';
if (!Email.equals(''))
soql += ' and Email includes (\''+Email+'\')';
// run the query again
runQuery();
return null;
}
}
// the soql without the order and limit
public String soql {get;set;}
// the collection of contacts to display
public List<Doctor__c> Doctor {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 = 'Contact_Area__c'; } 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 ContactSearchController1() {
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where 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 {
Doctor = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' ' + 'limit 10');
}
catch (Exception e) {
// for now, display exact error message for debugging purpose and see what is missing
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage() + ' ' + e.getLineNumber()));
//ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
}
}
// runs the search with parameters passed via Javascript
public PageReference runSearch() {
String ContactArea = Apexpages.currentPage().getParameters().get('Contact_Area__c');
String Speciality = Apexpages.currentPage().getParameters().get('Speciality__c');
String Qualification = Apexpages.currentPage().getParameters().get('Qualification__c');
String MoblieNumber = Apexpages.currentPage().getParameters().get('Mobile_Number__c');
String Email = Apexpages.currentPage().getParameters().get('Email');
soql = 'select name, Contact_Area__c, Speciality__c, Qualification__c,Mobile_Number__c,Email__c from Doctor__c where name != null';
if (!ContactArea.equals(''))
soql += ' and ContactAreaincludes (\''+ContactArea+'\')';
// if (!Contact_Area__c.equals(''))
// soql += ' and Contact_Area__c LIKE \''+String.escapeSingleQuotes(Contact)+'%\'';
if (!Speciality.equals(''))
soql += ' and Speciality LIKE \''+String.escapeSingleQuotes(Speciality)+'%\'';
if (!Qualification.equals(''))
soql += ' and Qualification LIKE \''+String.escapeSingleQuotes(Qualification)+'%\'';
if (!MoblieNumber.equals(''))
soql += ' and MoblieNumber includes (\''+MoblieNumber+'\')';
if (!Email.equals(''))
soql += ' and Email includes (\''+Email+'\')';
// run the query again
runQuery();
return null;
}
}
-------------------------------------------------------------------------------------------------------------------------------------------
<apex:page controller="ContactSearchController1" sidebar="false">
<apex:form >
<apex:pageMessages id="errors" />
<apex:pageBlock title="Find Me A Customer!" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="criteria">
<script type="text/javascript">
function doSearch() {
searchServer(
document.getElementById("Contact_Area__c").value,
document.getElementById("Speciality__c").value,
document.getElementById("Qualification__c ").value,
document.getElementById("Mobile_Number__c ").value,
);
}
</script>
<apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
<apex:param name="Contact Area" value="" />
<apex:param name="Speciality" value="" />
<apex:param name="Qualification" value="" />
<apex:param name="MobileNumber" value="" />
</apex:actionFunction>
<table cellpadding="2" cellspacing="2">
<tr>
<td style="font-weight:bold;">ContactArea<br/>
<input type="text" id="Contact_Area__c" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Speciality<br/>
<input type="text" id="Speciality__c" onkeyup="doSearch();"/>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Qulification<br/>
<input type="text" id="Qualification__c" onkeyup="doSearch();"/>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Doctor}" var="Doc">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="ContactArea" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Contact_Area__c" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Contact_Area__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Speciality" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Speciality__c" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Speciality__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Qualification" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="Qualification__c" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Doc.Qualification__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</td>
</tr>
</table>
<apex:pageBlock title="Debug - SOQL" id="debug">
<apex:outputText value="{!debugSoql}" />
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
This is my code i am change the small modification . can you found any mistake please modifie the code and send me