You need to sign in to do that
Don't have an account?
Sakthi Ganesh R
ERROR:: Unknown property 'AccountSearchController.Account'
Hi all,
My VF Page,
<apex:page controller="AccountSearchController" sidebar="false">
<apex:form>
<apex:pageBlock title="Find Accounts" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="pb2">
<table cellpadding="2" cellspacing="2">
<!-- <tr>
<td style="font-weight:bold;">Owner of Account<br/>
<apex:inputField value="{!Accounts.owner.id}" label="Owner of Account" id="owner" onkeyup="doSearch();"/>
</td>
</tr>-->
<tr>
<td style="font-weight:bold;">Type of Account<br/>
<select id="type" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!Type1}" var="type1">
<option value="{!type1}">{!type1}</option>
</apex:repeat>
</select>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Upsell Opportunity<br/>
<select id="Opportunity" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!upsell}" var="upsell">
<option value="{!upsell}">{!upsell}</option>
</apex:repeat>
</select>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Customer Priority<br/>
<select id="Priority" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!cusprity}" var="cusprity">
<option value="{!cusprity}">{!cusprity}</option>
</apex:repeat>
</select>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Accounts}" var="acc">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Acc.Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="acc.Name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Acc.Number" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="acc.Number" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.AccountNumber}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Annual Revenue" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="annualrevenue" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.AnnualRevenue}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Address" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="address" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Address}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Opportunities" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="upsellopportunity" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Upsellopportunity__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>
****************************************************************************
My Apex class,
public with sharing class AccountSearchController {
private string soql{get;set;}
public list<Account> Accounts{get;set;}
public string[] getType1()
{
return new string[]{'Prospect','Customer - Direct','Customer - Channel','Channel Partner / Reseller','Installation Partner','Technology Partner','Other'};
}
public string[] getupsell()
{
return new string[]{'Maybe','No','Yes'};
}
public string[] getcusprity()
{
return new string[]{'High','Medium','Low'};
}
public string sortDir
{
get
{
if(sortDir == null){sortDir = 'asc';} return sortDir;
}
set;
}
public string sortField
{
get
{
if(sortField == null){sortField = 'acc.Name';}return sortField;
}
set;
}
public string debugSoql
{
get
{
return soql+ 'order by' + sortField+' '+sortDir+' '+'limit 20';
}
}
public AccountSearchController()
{
soql = 'select Name,AccountNumber,Type,ownerid,AnnualRevenue,Address,UpsellOpportunity__c,Customerpriority__c from Account';
runquery();
}
public void toggleSort()
{
sortDir = sortDir.equals('asc')? 'desc': 'asc';
runquery();
}
public void runquery()
{
try
{
//accounts=new list<Account>();
accounts = Database.query(soql+' order by '+sortField+' '+sortDir+' limit 20');
}
catch(Exception e)
{
ApexPages.addmessage(new Apexpages.Message(Apexpages.Severity.ERROR,'oops!'));
}
}
public pagereference runSearch()
{
string owner = ApexPages.currentPage().getParameters().get('owner');
string type = ApexPages.currentPage().getParameters().get('type');
string Opporutnity = ApexPages.currentPage().getParameters().get('Opportunity');
string priority = ApexPages.currentPage().getparameters().get('priority');
soql = 'select Name,AccountNumber,Type,AnnualRevenue,Address,UpsellOpportunity__c,customerpriortiy__c from Account';
if(!owner.equals(' '))
soql += ' and owner LIKE\' '+string.escapeSingleQuotes(owner)+'%\'';
if(!type.equals(' '))
soql += ' and type LIKE\' '+string.escapeSingleQuotes(type)+'%\'';
//if(!Opportunity.equals(' '))
// soql += ' and UpsellOpportunity__c includes (\' '+Opportunity+'\')';
if(!priority.equals(' '))
soql += ' and priority LIKE\' '+string.escapeSingleQuotes(priority)+'%\'';
runquery();
return null;
}
}
I am getting Unknown property 'AccountSearchController.Account' Error when saving VF page. Any one can help me?
Thanks,
My VF Page,
<apex:page controller="AccountSearchController" sidebar="false">
<apex:form>
<apex:pageBlock title="Find Accounts" mode="edit">
<table width="100%" border="0">
<tr>
<td width="200" valign="top">
<apex:pageBlock title="Parameters" mode="edit" id="pb2">
<table cellpadding="2" cellspacing="2">
<!-- <tr>
<td style="font-weight:bold;">Owner of Account<br/>
<apex:inputField value="{!Accounts.owner.id}" label="Owner of Account" id="owner" onkeyup="doSearch();"/>
</td>
</tr>-->
<tr>
<td style="font-weight:bold;">Type of Account<br/>
<select id="type" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!Type1}" var="type1">
<option value="{!type1}">{!type1}</option>
</apex:repeat>
</select>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Upsell Opportunity<br/>
<select id="Opportunity" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!upsell}" var="upsell">
<option value="{!upsell}">{!upsell}</option>
</apex:repeat>
</select>
</td>
</tr>
<tr>
<td style="font-weight:bold;">Customer Priority<br/>
<select id="Priority" onchange="doSearch();">
<option value=""></option>
<apex:repeat value="{!cusprity}" var="cusprity">
<option value="{!cusprity}">{!cusprity}</option>
</apex:repeat>
</select>
</td>
</tr>
</table>
</apex:pageBlock>
</td>
<td valign="top">
<apex:pageBlock mode="edit" id="results">
<apex:pageBlockTable value="{!Accounts}" var="acc">
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Acc.Name" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="acc.Name" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Acc.Number" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="acc.Number" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.AccountNumber}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Annual Revenue" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="annualrevenue" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.AnnualRevenue}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Address" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="address" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Address}"/>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:commandLink value="Opportunities" action="{!toggleSort}" rerender="results,debug">
<apex:param name="sortField" value="upsellopportunity" assignTo="{!sortField}"/>
</apex:commandLink>
</apex:facet>
<apex:outputField value="{!Account.Upsellopportunity__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>
****************************************************************************
My Apex class,
public with sharing class AccountSearchController {
private string soql{get;set;}
public list<Account> Accounts{get;set;}
public string[] getType1()
{
return new string[]{'Prospect','Customer - Direct','Customer - Channel','Channel Partner / Reseller','Installation Partner','Technology Partner','Other'};
}
public string[] getupsell()
{
return new string[]{'Maybe','No','Yes'};
}
public string[] getcusprity()
{
return new string[]{'High','Medium','Low'};
}
public string sortDir
{
get
{
if(sortDir == null){sortDir = 'asc';} return sortDir;
}
set;
}
public string sortField
{
get
{
if(sortField == null){sortField = 'acc.Name';}return sortField;
}
set;
}
public string debugSoql
{
get
{
return soql+ 'order by' + sortField+' '+sortDir+' '+'limit 20';
}
}
public AccountSearchController()
{
soql = 'select Name,AccountNumber,Type,ownerid,AnnualRevenue,Address,UpsellOpportunity__c,Customerpriority__c from Account';
runquery();
}
public void toggleSort()
{
sortDir = sortDir.equals('asc')? 'desc': 'asc';
runquery();
}
public void runquery()
{
try
{
//accounts=new list<Account>();
accounts = Database.query(soql+' order by '+sortField+' '+sortDir+' limit 20');
}
catch(Exception e)
{
ApexPages.addmessage(new Apexpages.Message(Apexpages.Severity.ERROR,'oops!'));
}
}
public pagereference runSearch()
{
string owner = ApexPages.currentPage().getParameters().get('owner');
string type = ApexPages.currentPage().getParameters().get('type');
string Opporutnity = ApexPages.currentPage().getParameters().get('Opportunity');
string priority = ApexPages.currentPage().getparameters().get('priority');
soql = 'select Name,AccountNumber,Type,AnnualRevenue,Address,UpsellOpportunity__c,customerpriortiy__c from Account';
if(!owner.equals(' '))
soql += ' and owner LIKE\' '+string.escapeSingleQuotes(owner)+'%\'';
if(!type.equals(' '))
soql += ' and type LIKE\' '+string.escapeSingleQuotes(type)+'%\'';
//if(!Opportunity.equals(' '))
// soql += ' and UpsellOpportunity__c includes (\' '+Opportunity+'\')';
if(!priority.equals(' '))
soql += ' and priority LIKE\' '+string.escapeSingleQuotes(priority)+'%\'';
runquery();
return null;
}
}
I am getting Unknown property 'AccountSearchController.Account' Error when saving VF page. Any one can help me?
Thanks,
For example <apex:outputField value="{!Account.Name}"/>, this should be changed with
<apex:outputField value="{!acc.Name}"/>
Also I see one more problem with VF. the expression {!Accounts.owner.id} is incorrect.
<apex:inputField value="{!Accounts.owner.id}" label="Owner of Account" id="owner" onkeyup="doSearch();"/>
Accounts is a list and it does not have a owner unless you get the first element.,
you can add one more property for User on the controller and use that property in the VF page