• CRM ADMIN 19
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Hi,

I would be really grateful if someone can help me! I'm getting crazy trying to write a test class for an extended class used in a visualforce. Now I'm getting next error but I can't really understand

Error: Compile Error: Constructor not defined: [IN_Local_SalesEdit].<Constructor>(ApexPages.StandardController) at line 17 column 40

Here is my class

public with sharing class IN_Local_SalesEdit {
    ApexPages.StandardSetController con ;
    
    List<IN_Local_Sales__c> editLS = new List<IN_Local_Sales__c>();
    
    string strAccountAuxId;
    date currentDate;
      
    public IN_Local_SalesEdit(ApexPages.StandardSetController controller) {
          this.con = controller ; 
          string strAccountId; 
          strAccountId = ApexPages.currentPage().getParameters().get('id');
          strAccountAuxId = strAccountId ;
          editLS = con.getSelected();
          
          currentDate = Date.today();
          
          Set <Id> aIds = new Set<Id>();
          for(IN_Local_Sales__c act : editLS){
            aIds.add(act.Id);
          }
          editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountId AND MonthNumber__c =: currentDate.month()-1 ORDER BY Month__c,Country__c,Producto__c ASC];       
          con.setSelected(editLS); 
    }
    
    public PageReference Filter() {
          
          String strMonth = Apexpages.currentPage().getParameters().get('months'); 
          String strCountry = Apexpages.currentPage().getParameters().get('countries');
          
                if(!strMonth.equals(''))
                {
                    if (!strCountry.equals(''))
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Month__c =:strMonth AND Country__c =:strCountry AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                    else
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Month__c =:strMonth AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                }
                else
                {   
                    if (!strCountry.equals(''))
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Country__c =:strCountry AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                    else
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                }   
                con.setSelected(editLS);
                return null;
            }  
    
    public List<String> months{
    get {
      if (months == null) {
 
        months = new List<String>();
        Schema.DescribeFieldResult field = IN_Local_Sales__c.Month__c.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
          months.add(f.getLabel());
 
      }
      return months;          
    }
    set;
  }
  public List<String> countries{
    get {
      if (countries== null) {
 
        countries= new List<String>();
        Schema.DescribeFieldResult field = IN_Local_Sales__c.Country__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          countries.add(f.getLabel());
 
      }
      return countries;          
    }
    set;
  }
  public PageReference customSave(){

    PageReference pr = ApexPages.currentPage();
    
    try {
        upsert editLS ;
        pr.setRedirect(true);
    }
    catch (Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops Complete mandatory info please!'));
    }
    
    return pr;
  }
    
}

My Test Class

@isTest
public class testIN_Local_Sales_Edit {
    static testMethod void IN_Local_Sales_Edit_Test()
    {
        //Test converage for the myPage visualforce page
        PageReference pageRef = Page.IN_Local_Sales_Edit;
        Test.setCurrentPageReference(pageRef);
        Account newAccount = new Account (name='XYZ Organization');
        insert newAccount;
        //create first sales record
        IN_Local_Sales__c mySales = new IN_Local_Sales__c (In_market_Sales_UN_Bdg__c=1000,
        Account__c=newAccount.id);
        insert mySales;
        ApexPages.StandardController sc = new ApexPages.standardController(mySales);
        // create an instance of the controller
        IN_Local_SalesEdit myPageCon = new IN_Local_SalesEdit (sc);
      
    }
}

And myPage

<apex:page StandardController="IN_Local_Sales__c" recordSetVar="IN_Local_Sales__c" extensions="IN_Local_SalesEdit"> <apex:form > <apex:pageBlock title="Filters" mode="edit" id="criteria"> <script type="text/javascript"> function doSearch() { searchServer( document.getElementById("months").value, document.getElementById("countries").value) ; } </script> <apex:actionFunction name="searchServer" action="{!Filter}" rerender="results"> <apex:param name="months" value="" /> <apex:param name="countries" value="" /> </apex:actionFunction> <table> <tr> <td style="font-weight:bold;">Month<br/> <select id="months" onchange="doSearch();"> <option value=""></option> <apex:repeat value="{!months}" var="mon"> <option value="{!mon}">{!mon}</option> </apex:repeat> </select> </td> </tr> <tr> <td style="font-weight:bold;">Country<br/> <select id="countries" onchange="doSearch();"> <option value=""></option> <apex:repeat value="{!countries}" var="con"> <option value="{!con}">{!con}</option> </apex:repeat> </select> </td> </tr> </table> </apex:pageBlock> <apex:pageBlock title="Edit Local Sales" mode="edit" id="results"> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!customsave}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockTable value="{!selected}" var="ql"> <apex:column headerValue="Month"><apex:outputField value="{!ql.Month__c}"/></apex:column> <apex:column headerValue="Country"><apex:outputField value="{!ql.Country__c}"/></apex:column> <apex:column headerValue="Product SKU"><apex:outputField value="{!ql.Producto__c}"/></apex:column> <apex:column headerValue="Market Sales UN"><apex:inputField value="{!ql.In_market_Sales_UN_Real__c}" /></apex:column> <apex:column headerValue="Market Sales VAL"><apex:inputField value="{!ql.In_market_Sales_VAL_Real__c}" /></apex:column> <apex:column headerValue="Purchases"><apex:inputField value="{!ql.Purchases__c}" /></apex:column> <apex:column headerValue="Stock at the end of month"><apex:inputField value="{!ql.Stock_at_the_end_of_month__c}" /></apex:column> <apex:column headerValue="Price ExFactory"><apex:inputField value="{!ql.Price_ExFactory__c}" /></apex:column> <apex:column headerValue="Comments"><apex:inputField value="{!ql.Comments__c}"/></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

Could you help me please?

Thanks in advance!
Ivan
Hi,

I would be really grateful if someone can help me! I'm getting crazy trying to write a test class for an extended class used in a visualforce. Now I'm getting next error but I can't really understand

Error: Compile Error: Constructor not defined: [IN_Local_SalesEdit].<Constructor>(ApexPages.StandardController) at line 17 column 40

Here is my class

public with sharing class IN_Local_SalesEdit {
    ApexPages.StandardSetController con ;
    
    List<IN_Local_Sales__c> editLS = new List<IN_Local_Sales__c>();
    
    string strAccountAuxId;
    date currentDate;
      
    public IN_Local_SalesEdit(ApexPages.StandardSetController controller) {
          this.con = controller ; 
          string strAccountId; 
          strAccountId = ApexPages.currentPage().getParameters().get('id');
          strAccountAuxId = strAccountId ;
          editLS = con.getSelected();
          
          currentDate = Date.today();
          
          Set <Id> aIds = new Set<Id>();
          for(IN_Local_Sales__c act : editLS){
            aIds.add(act.Id);
          }
          editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountId AND MonthNumber__c =: currentDate.month()-1 ORDER BY Month__c,Country__c,Producto__c ASC];       
          con.setSelected(editLS); 
    }
    
    public PageReference Filter() {
          
          String strMonth = Apexpages.currentPage().getParameters().get('months'); 
          String strCountry = Apexpages.currentPage().getParameters().get('countries');
          
                if(!strMonth.equals(''))
                {
                    if (!strCountry.equals(''))
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Month__c =:strMonth AND Country__c =:strCountry AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                    else
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Month__c =:strMonth AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                }
                else
                {   
                    if (!strCountry.equals(''))
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND Country__c =:strCountry AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                    else
                    {
                        editLS = [SELECT In_market_Sales_UN_Real__c,In_market_Sales_VAL_Real__c, Month__c, Name, Id,Purchases__c,Stock_at_the_end_of_month__c,Price_ExFactory__c, Producto__c,Comments__c, Country__c FROM IN_Local_Sales__c WHERE Account__c=:strAccountAuxId AND MonthNumber__c <:currentDate.month() ORDER BY Month__c,Country__c,Producto__c ASC];
                    }
                }   
                con.setSelected(editLS);
                return null;
            }  
    
    public List<String> months{
    get {
      if (months == null) {
 
        months = new List<String>();
        Schema.DescribeFieldResult field = IN_Local_Sales__c.Month__c.getDescribe();
 
        for (Schema.PicklistEntry f : field.getPicklistValues())
          months.add(f.getLabel());
 
      }
      return months;          
    }
    set;
  }
  public List<String> countries{
    get {
      if (countries== null) {
 
        countries= new List<String>();
        Schema.DescribeFieldResult field = IN_Local_Sales__c.Country__c.getDescribe();
        for (Schema.PicklistEntry f : field.getPicklistValues())
          countries.add(f.getLabel());
 
      }
      return countries;          
    }
    set;
  }
  public PageReference customSave(){

    PageReference pr = ApexPages.currentPage();
    
    try {
        upsert editLS ;
        pr.setRedirect(true);
    }
    catch (Exception e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops Complete mandatory info please!'));
    }
    
    return pr;
  }
    
}

My Test Class

@isTest
public class testIN_Local_Sales_Edit {
    static testMethod void IN_Local_Sales_Edit_Test()
    {
        //Test converage for the myPage visualforce page
        PageReference pageRef = Page.IN_Local_Sales_Edit;
        Test.setCurrentPageReference(pageRef);
        Account newAccount = new Account (name='XYZ Organization');
        insert newAccount;
        //create first sales record
        IN_Local_Sales__c mySales = new IN_Local_Sales__c (In_market_Sales_UN_Bdg__c=1000,
        Account__c=newAccount.id);
        insert mySales;
        ApexPages.StandardController sc = new ApexPages.standardController(mySales);
        // create an instance of the controller
        IN_Local_SalesEdit myPageCon = new IN_Local_SalesEdit (sc);
      
    }
}

And myPage

<apex:page StandardController="IN_Local_Sales__c" recordSetVar="IN_Local_Sales__c" extensions="IN_Local_SalesEdit"> <apex:form > <apex:pageBlock title="Filters" mode="edit" id="criteria"> <script type="text/javascript"> function doSearch() { searchServer( document.getElementById("months").value, document.getElementById("countries").value) ; } </script> <apex:actionFunction name="searchServer" action="{!Filter}" rerender="results"> <apex:param name="months" value="" /> <apex:param name="countries" value="" /> </apex:actionFunction> <table> <tr> <td style="font-weight:bold;">Month<br/> <select id="months" onchange="doSearch();"> <option value=""></option> <apex:repeat value="{!months}" var="mon"> <option value="{!mon}">{!mon}</option> </apex:repeat> </select> </td> </tr> <tr> <td style="font-weight:bold;">Country<br/> <select id="countries" onchange="doSearch();"> <option value=""></option> <apex:repeat value="{!countries}" var="con"> <option value="{!con}">{!con}</option> </apex:repeat> </select> </td> </tr> </table> </apex:pageBlock> <apex:pageBlock title="Edit Local Sales" mode="edit" id="results"> <apex:pageBlockButtons location="top"> <apex:commandButton value="Save" action="{!customsave}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <apex:pageMessages /> <apex:pageBlockTable value="{!selected}" var="ql"> <apex:column headerValue="Month"><apex:outputField value="{!ql.Month__c}"/></apex:column> <apex:column headerValue="Country"><apex:outputField value="{!ql.Country__c}"/></apex:column> <apex:column headerValue="Product SKU"><apex:outputField value="{!ql.Producto__c}"/></apex:column> <apex:column headerValue="Market Sales UN"><apex:inputField value="{!ql.In_market_Sales_UN_Real__c}" /></apex:column> <apex:column headerValue="Market Sales VAL"><apex:inputField value="{!ql.In_market_Sales_VAL_Real__c}" /></apex:column> <apex:column headerValue="Purchases"><apex:inputField value="{!ql.Purchases__c}" /></apex:column> <apex:column headerValue="Stock at the end of month"><apex:inputField value="{!ql.Stock_at_the_end_of_month__c}" /></apex:column> <apex:column headerValue="Price ExFactory"><apex:inputField value="{!ql.Price_ExFactory__c}" /></apex:column> <apex:column headerValue="Comments"><apex:inputField value="{!ql.Comments__c}"/></apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

Could you help me please?

Thanks in advance!
Ivan

This error doesn't make any sense. The only way that I can include a custom field in the

object's searchResultsField is thru the SFC interface from the object. ( at least as far as

i know...)

 

The field that SFC is referencing in my deploy error message is in the list of fields available

to add to to search results. How else could I have added it?

 

I double checked the object. The field is there. It's not a case of where I added a field,

modified the searchResults and then deleted the field.

 

 

Any thoughts on this error would be appreciated. I received five other errors just like this

one on other custom objects I was trying to deploy to production.