Please help me figure out a way on how to solve this. The below query gives me error :
Error: Compile Error: Didn't understand relationship 'contactData' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 18 column 27
displayContacts = [select id,
Name,
Domain__c,
City__c,
FirstName,
LastName,
Email,
Country__c from Contact where
(Domain__c=:contactData.Domain__c OR contactData.Domain__c==NULL)
AND (City__c=:contactData.City__c OR contactData.City__c == NULL)
AND (Country__c=:contactData.Country__c OR contactData.Country__c == NULL];
I am trying to use the value generated from Visualforce page to add condition in the query.
myClass
class getpicklstval1{
public String searchString {get;set;}
public Boolean allContacts{get;set;}
public Contact ContactData{get;set;}
public List<Contact> displayContacts{get;set;}
public getpicklstval1(ApexPages.StandardController controller){
ContactData = new Contact();
displayContacts = new List<Contact>();
}
public void called(){
if(contactData.Domain__c!=NULL && contactData.City__c!=NULL && contactData.Country__c!=NULL){
displayContacts = [select id,
Name,
Domain__c,
City__c,
FirstName,
LastName,
Email,
Country__c from Contact where
(Domain__c=:contactData.Domain__c OR contactData.Domain__c==NULL)
AND (City__c=:contactData.City__c OR contactData.City__c == NULL)
AND (Country__c=:contactData.Country__c OR contactData.Country__c == NULL];
}
}
public List<Contact> getreturnContact(){
return displayContacts;
}
public void SearchKeyword(){
} }
Visualforce Page
<apex:page StandardController="Contact" extensions="getpicklstval1">
<apex:form >
<apex:inputField id="Domain" value="{!ContactData.Domain__c}" style="width:159px;">
<apex:actionSupport event="onchange" action="{!called}" rerender="displayContacts"/>
</apex:inputfield>
<apex:inputField id="City" value="{!ContactData.City__c}" style="width:159px;">
<apex:actionSupport event="onchange" action="{!called}" rerender="displayContacts"/>
</apex:inputfield>
<apex:inputField id="Country" value="{!ContactData.Country__c}" style="width:159px;">
<apex:actionSupport event="onchange" action="{!called}" rerender="displayContacts"/>
</apex:inputfield>
<apex:pageBlock id="displayContacts">
<apex:pageblockTable id="searchContactList" var="contact" value="{!returnContact}">
<apex:column style="width:3px;">
<apex:facet name="header"/>
<apex:inputCheckbox value="{!contact.Name}" id="checkedone" style="width:15px;">
</apex:inputCheckbox>
</apex:column>
<apex:column style="width:200px; height:60px;">
<apex:facet name="header">
<apex:outputPanel layout="block" style="text-align:center;">
First Name
</apex:outputPanel>
</apex:facet>
<apex:outputLink value="/{!contact.id}">{!contact.FirstName}</apex:outputLink>
</apex:column>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>