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
michael_mcmahonmichael_mcmahon 

Error: Unknown constructor 'PricebookEntry.PricebookEntry()'

I'm trying to adapt some code from Jeff Douglass that I know works, but my changes break it.  For starters, I get the error "Unknown Constructor 'PricebookEntry.PricebookEntry()'" and I can't even find where this refers to.  Any help appreciated, thank you.

 

  <apex:page controller="PricebookEntry" sidebar="false">
 
  <apex:form >
  <apex:pageMessages id="errors" />
 
  <apex:pageBlock title="Find A Product" mode="edit">
 
  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">
 
      <apex:pageBlock title="Parameters" mode="edit" id="criteria">
 
      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("product2ID").value,
          document.getElementById("Name").value,
          document.getElementById("description").value,
          document.getElementById("unitprice").value
          );
      }
      </script> 
 
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="Product2ID" value="" />
          <apex:param name="Name" value="" />
          <apex:param name="description" value="" />
          <apex:param name="unitprice" value="" />
      </apex:actionFunction>
 
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Name<br/>
        <input type="text" id="Name" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Description<br/>
        <input type="text" id="description" onkeyup="doSearch();"/>
        </td>
      </tr>
          <tr>
          <td style="font-weight:bold;">product2ID<br/>
          <input type="text" id="Product2ID" onkeyup="doSearch();"/>
          </td>
          </tr>
         
      </table>
 
      </apex:pageBlock>
 
    </td>
    <td valign="top">
 
    <apex:pageBlock mode="edit" id="results">
 
        <apex:pageBlockTable value="{!name}" var="product">
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Name}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Description" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Description" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!Description}"/>
            </apex:column>
 
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Product2ID" action="{!toggleSort}" rerender="results,debug">
                    // <apex:param name="sortField" value="pricebookentry.name" assignTo="{!sortField}"/>
                    // </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!product2id}"/>
            </apex:column>
 
            //<apex:column >
            //  <apex:facet name="header">
            //        <apex:commandLink value="Technologies" action="{!toggleSort}" rerender="results,debug">
            //            <apex:param name="sortField" value="interested_technologies__c" assignTo="{!sortField}"/>
            //        </apex:commandLink>
            //    </apex:facet>
            //     <apex:outputField value="{!contact.Interested_Technologies__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>

 

Best Answer chosen by Admin (Salesforce Developers) 
michael_mcmahonmichael_mcmahon

All Answers

Lucky_mLucky_m

Can you provide the controller code as well,

So that it would be helpful to understand the basic logic behind your code.

Thank you.

Regards

 

michael_mcmahonmichael_mcmahon
public with sharing class Pricebook {

    //the soql without the order and limit
    private String soql {get;set;}
	//the collection of PricebookEntrys to display
    public List<PricebookEntry> pricebookentries { get; set; }
 
  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }
 
  // the current field to sort by. defaults to name
  public String sortField {
    get  { if (sortField == null) {sortField = 'name'; } return sortField;  }
    set;
  }
 
  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }
 
  // init the controller and display some sample data when the page loads
  public Pricebook() {
    soql = 'select product2id, name, description, unitprice from PricebookEntry where name != null and IsActive = True';
    runQuery();
  }
 
  // toggles the sorting of query from asc<-->desc
  //public void toggleSort() {
    //// simply toggle the direction
    //sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    //// run the query again
    //runQuery();
 // }
 
  // runs the actual query
  public void runQuery() {
 
    try {
      pricebookentries = Database.query(soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }
 
  }
 
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {
 
    String name = Apexpages.currentPage().getParameters().get('name');
    String description = Apexpages.currentPage().getParameters().get('description');
    String unitPrice = Apexpages.currentPage().getParameters().get('unitPrice');
    String product2ID = Apexpages.currentPage().getParameters().get('Product2ID');
   
 
    soql = 'select name, description from Pricebook where name != null';
    if (!name.equals(''))
      soql += ' and name LIKE \''+String.escapeSingleQuotes(name)+'%\'';
    if (!description.equals(''))
      soql += ' and description LIKE \''+String.escapeSingleQuotes(description)+'%\'';
     
      
 
    // run the query again
    runQuery();
 
    return null;
  }
 
  // use apex describe to build the picklist values
  //public List<String> technologies{
  //  get {
 //     if (technologies == null) {
 //
  //      picklist = new List<String>();
  //      Schema.DescribeFieldResult field = picklist.Description.getDescribe();
 //
  //      for (Schema.PicklistEntry f : field.getPicklistValues())
 //         picklist.add(f.getLabel());
 
  //    }
 //     return picklist;          
 //   }
   // set;
 // }
}

 

michael_mcmahonmichael_mcmahon
This was selected as the best answer
michael_mcmahonmichael_mcmahon

Salesforce support comes through!  They fixed the code.  I will post if anyone asks.