You need to sign in to do that
Don't have an account?

Hi All, I am new in sales force. My requirement is like i want to search Contacts based on Last Name.
I Create a VF page with below Code
apex:page Controller="ContactNomineeController" showHeader="True">
<apex:image value="{!$Resource.Contact}" width="500" height="100"/>
<apex:form >
<apex:actionFunction action="{doquery}" name="QueryContact" reRender="MyContact"/>
<div class="filterDiv">
<label>Filter By Last Name:</label>
<apex:inputText value="{!serachstring}" onkeyup="apexDoQuery()"/>
</div>
<apex:pageBlock title="Search Contact" id="MyContact">
<apex:pageBlockButtons >
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!ConList}" var="Con">
<apex:column value="{!Con.Name}"/>
<apex:column value="{!Con.accountid}"/>
<apex:column headerValue="Email">
<apex:inputField value="{!Con.email}" />
</apex:column>
<apex:column value="{!Con.phone}"/>
<apex:column headerValue="Nominee">
<apex:inputCheckbox value="{!Con.Nominee__c}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
and Controller Class
public with sharing class ContactNomineeController {
Public List<Contact> ConList {get;set;}
Public List<Contact> Contacts {get;set;}
Public String serachstring {get;set;}
Public ContactNomineeController (){
serachstring='';
doquery();
}
Public void doquery(){
String querystring='';
if (serachstring!= null)
querystring = '%' +serachstring+ '%';
ConList= [select id,accountid,name,email,phone,Nominee__C from Contact where lastname like :querystring LIMIT 10 ];
}
Public void save() {
update ConList; }
}
Code saved but not able to search contact.
Need help to understand the loophole.
apex:page Controller="ContactNomineeController" showHeader="True">
<apex:image value="{!$Resource.Contact}" width="500" height="100"/>
<apex:form >
<apex:actionFunction action="{doquery}" name="QueryContact" reRender="MyContact"/>
<div class="filterDiv">
<label>Filter By Last Name:</label>
<apex:inputText value="{!serachstring}" onkeyup="apexDoQuery()"/>
</div>
<apex:pageBlock title="Search Contact" id="MyContact">
<apex:pageBlockButtons >
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!ConList}" var="Con">
<apex:column value="{!Con.Name}"/>
<apex:column value="{!Con.accountid}"/>
<apex:column headerValue="Email">
<apex:inputField value="{!Con.email}" />
</apex:column>
<apex:column value="{!Con.phone}"/>
<apex:column headerValue="Nominee">
<apex:inputCheckbox value="{!Con.Nominee__c}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
and Controller Class
public with sharing class ContactNomineeController {
Public List<Contact> ConList {get;set;}
Public List<Contact> Contacts {get;set;}
Public String serachstring {get;set;}
Public ContactNomineeController (){
serachstring='';
doquery();
}
Public void doquery(){
String querystring='';
if (serachstring!= null)
querystring = '%' +serachstring+ '%';
ConList= [select id,accountid,name,email,phone,Nominee__C from Contact where lastname like :querystring LIMIT 10 ];
}
Public void save() {
update ConList; }
}
Code saved but not able to search contact.
Need help to understand the loophole.
Try the below code.It works for me
Hope it will satistify your requirement
Regards,
Vignesh.B
Thanks!
but i tried to search the contact using apex:action function and for that i define do query method . but it only refersh the page. how can we solve this.