function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sivasankari MuthuSivasankari Muthu 

Error:Unknown property 'customref.Account'

Hi everyone,
    I am getting error  " Unknown property 'customref.Account' " in  VisualForce Page. Please review the code.
Let me know where i did mistake.

Thanks in Advance,
SivaSankari

Apex Code:
Public with sharing class customref{
 Public List<Account> acc{get;set;} 
    public String imageURL{get;set;}
 Public String searchStr{get;set;} // find a string

    /* display a image -method*/
 public  customref()
  {
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
   
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
    
    /* find a string and  run the sosl query*/
  Public void soslDemo_method(){
   acc = New List<Account>();
 
   if(searchStr.length() > 1){
   String searchStr1 = searchStr;
       String searchQuery = 'FIND \'' + searchStr1 + '\' IN ALL FIELDS RETURNING  Account( Firstname,lastname )';
   List<List <sObject>> searchList = search.query(searchQuery);
   acc= ((List<Account>)searchList[0]);
       /* Message */
   if(acc.size() == 0){
       apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
       return;
   }
   }
   else{
   apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please select the industry..'));
   return;
   }
  }
}

VF Code ;
<apex:page  controller="customref" tabstyle="Account" >
  <apex:form >
       <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry" >
                 <apex:outputLabel value="Inustry:"/>
                 <apex:inputfield  value="{! Account.Industry}"/>   
    <apex:commandButton value="Submit" action="{!customref}"  />
   </apex:pageBlock>
    <apex:pageBlock title="Customer details">
    <apex:pageblockTable value="{!Account }" var="acc">
      
          <apex:column value="{!acc.Firstname}"/>
         <apex:column value="{!acc.lastname}"/>
          
       </apex:pageblockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 
Best Answer chosen by Sivasankari Muthu
VinodKRVinodKR
Hi SivaSankari,

This should work.

Page :

<apex:page controller="sfdctest">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry" >
         <apex:outputLabel value="Inustry:"/>
          <apex:selectList value="{!searchStr}" size="1"> 
               <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>
         <apex:commandButton value="Submit" action="{!soslDemo_method}" ReRender="pgId,pId" />
      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
    <apex:pageblockTable value="{!acc}" var="account">
         <apex:column value="{!account.name}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:

Public with sharing class sfdctest{

 Public List<Account> acc{get;set;} 
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 
public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues();               
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    }           
    return options; 
}
 
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
 
  Public void soslDemo_method(){
   if(searchStr.length() > 1){
       acc = [SELECT Name FROM Account WHERE Industry =:searchStr];
       if(acc.size() == 0){
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
           return;
       }
   }
   else{
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please select the industry..'));
       return;
   }
  }
}


Thanks,

Have a great day ahead,Let the Force be with you!
Please mark this as best answer if it helps you.

All Answers

VinodKRVinodKR
Hi Sivasankari,

Here is the modifed code which works fine:

Page:

<apex:page controller="sfdctest">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry" >
         <apex:outputLabel value="Inustry:"/>
         <apex:inputtext value="{!searchStr}"/>
         <apex:commandButton value="Submit" action="{!soslDemo_method}" ReRender="pgId,pId" />
      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
    <apex:pageblockTable value="{!acc}" var="account">
         <apex:column value="{!account.name}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:

Public with sharing class sfdctest{
 Public List<Account> acc{get;set;} 
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 

 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
 
  Public void soslDemo_method(){
   if(searchStr.length() > 1){
       acc = [SELECT Name FROM Account WHERE Industry =:searchStr];
       if(acc.size() == 0){
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
           return;
       }
   }
   else{
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please select the industry..'));
       return;
   }
  }
}

Thanks,

Have a great day ahead!
Let the Force be with you!
Please mark this as best answer if it helps you.
Sivasankari MuthuSivasankari Muthu
Hi  VinodKR,
Thanks for your reply.
 The Input industry field ,i want from an account picklist. you mentioned as  a textbox.
if you know the code please reply me..

Thanks,
SivaSankari
VinodKRVinodKR
Hi SivaSankari,

This should work.

Page :

<apex:page controller="sfdctest">
<apex:form >
<apex:pageMessages id="pId"/>
    <apex:image url="{!imageURL}">
    </apex:image>
      <apex:pageBlock title="Select a Industry" >
         <apex:outputLabel value="Inustry:"/>
          <apex:selectList value="{!searchStr}" size="1"> 
               <apex:selectOptions value="{!Industrynames}" />
          </apex:selectList>
         <apex:commandButton value="Submit" action="{!soslDemo_method}" ReRender="pgId,pId" />
      </apex:pageBlock>
    
    <apex:pageBlock title="Customer details" id="pgId">
    <apex:pageblockTable value="{!acc}" var="account">
         <apex:column value="{!account.name}"/>
       </apex:pageblockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>

Controller:

Public with sharing class sfdctest{

 Public List<Account> acc{get;set;} 
 public String imageURL{get;set;}
 Public String searchStr{get;set;} 
 
public List<selectoption> getIndustrynames()
{           
    list<selectoption> options = new list<selectoption>();            
    Schema.DescribeFieldResult fieldResult = Account.Industry.getDescribe();
    list<schema.picklistentry> values = fieldResult.getPickListValues();               
    for (Schema.PicklistEntry a : values) 
    {                  
        options.add(new SelectOption(a.getLabel(), a.getValue()));
    }           
    return options; 
}
 
 public  sfdctest()
  {
    acc = New List<Account>();
    imageURL='/servlet/servlet.FileDownload?file=';
    List< document > documentList=[select name from document where 
                                    Name='logo'];
    if(documentList.size()>0)
    {
      imageURL=imageURL+documentList[0].id;
    }
  }
 
  Public void soslDemo_method(){
   if(searchStr.length() > 1){
       acc = [SELECT Name FROM Account WHERE Industry =:searchStr];
       if(acc.size() == 0){
           apexPages.addmessage(new apexpages.message(apexpages.severity.WARNING, 'Sorry, data not found'));
           return;
       }
   }
   else{
       apexPages.addmessage(new apexpages.message(apexpages.severity.Error, 'Please select the industry..'));
       return;
   }
  }
}


Thanks,

Have a great day ahead,Let the Force be with you!
Please mark this as best answer if it helps you.
This was selected as the best answer
Sivasankari MuthuSivasankari Muthu
Hi  VinodKR,

Thanks,its working...