+ Start a Discussion
sales@myvarmasales@myvarma 

only aggregate expressions use field aliasing Unknown property 'oppsearch.searchText'

only aggregate expressions use field aliasing
Unknown property 'oppsearch.searchText'



i got two errors in program
public class oppsearch 
{

   String searchText;
   List<opportunity> results;

   public String getSearchText()
   {
      return searchText;
   }

   public void setSearchText(String s) 
   {
      searchText = s;
   }

   public List<opportunity> getResults()
   {
      return results;
   }

   public PageReference doSearch() {
      results = (List<opportunity>)[FIND :searchText RETURNING opportunity(Account name, amount, Phone)][0];
      return null;
   }

}



<apex:page controller="oppsearch ">
   <apex:form >
      <apex:pageBlock mode="edit" id="block">
         <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Go!" action="{!doSearch}" 
                                      rerender="block" status="status"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:actionStatus id="status" startText="requesting..."/>
        <apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="l" 
                               rendered="{!NOT(ISNULL(results))}">
              <apex:column value="{!l.account name}"/>
              <apex:column value="{!l.phone}"/>
               <apex:column value="{!l.amount}"/>
           </apex:pageBlockTable>
        </apex:pageBlockSection>
      </apex:pageBlock>
   </apex:form>
</apex:page>
                    


 
Shivdeep KumarShivdeep Kumar
Hi,
Please take a look on below code !
public class oppsearch 
{

    public String searchText{get;set;}
    public List<opportunity> results{get;set;}

   public String getsearchText()
   {
      return searchText;
   }

   public void setsearchText(String s) 
   {
      searchText = s;
   }

   public List<opportunity> getresults()
   {
      return results;
   }

   public PageReference doSearch() {
        String searchTxt1 = '*'+searchText+'*';
       String searchQuery = 'FIND \'' + searchTxt1 + '\' IN ALL FIELDS RETURNING  opportunity(AccountName, amount, Phone)';
         	
       List<List <sObject>> searchList = search.query(searchQuery);
       	results = ((List<opportunity>)searchList[0]);
      return null;
   }

}

Thanks
Shivdeep