-2

I am very new to this. This is my first apex and VF page. So please bare with me.

I am getting the error:

Unknown constructor customMutliSelectLookUpCntrl.customMutliSelectLookUpCntrl(Billing_Change_Form__c controller)

I cant fix the error. Here is the extension code:

public with sharing class customMutliSelectLookUpCntrl {

    //Declare Variable
    public List<Contingency__c> caseFindings {get;set;}
    public String searchString {get;set;}
    public List<Billing_Change_Form__c> bills {get;set;}
    private final Billing_Change_form__c bcf{get;set;}

    //Page Reference
    ApexPages.StandardController bcfCtrl;

    //Constructor 
    public customMutliSelectLookUpCntrl(ApexPages.StandardController controller)
    {   
        this.bcf = (Billing_Change_Form__c)controller.getRecord();
        bcfCtrl = controller;
        caseFindings = [select id, name, billing_type__c, report_description__c, discovery_amount__c,
                        billing_begins_date__c,  contingency__c from contingency__c
                       WHERE Id = :ApexPages.currentPage().getParameters().get('id') 
                       ];

        bills = [select id, account__c, billing_status__c, Case_finding__c, status__c, reason_what_why__c
                from billing_change_form__c
                WHERE Id = :ApexPages.currentPage().getParameters().get('id')];

        searchString='';

        doQuery();

    }


    //Method for searching 

    public void doQuery()
    {
        String queryString= '';
        if(searchString !=null) //add in % in the query string
            queryString = '%' +searchString+ '%';

        caseFindings = [select id, name, billing_type__c, report_description__c, discovery_amount__c,
                        billing_begins_date__c, contingency__c from contingency__c ca
                       where name like :queryString]; //Add criteria to search by
    }

    //Saving Records after updating 
    public void save(){
        update caseFindings;
    }

    //Cancel the transaction 


}

My VF page declaration

<apex:page showHeader="False" controller="Billing_Change_form__c" extensions="customMutliSelectLookUpCntrl">

Billing_Change_form__c and contingency__c are custom objects.

Also, I ham trying to associate the account(lookup field) in Billing_Change_Form__c. How would I accomplish it. Any guidance will be appreciated!

Edit: I have not got to the testing part yet. It is showing up at dev console. Is it ok to write a soql statement from a different custom object (contingency__c) in controller while I do not have it in VF page?

Edit 2: Right now, I am using the preview button on the dev console. I would like to have a custom button on a field on Billing_Change_form__c that pops out a new window with that VF page

Fixed: There was a mistake on my VF page declaration

apex:page showHeader="False" standardcontroller="Billing_Change_form__c" extensions="customMutliSelectLookUpCntrl"

  • 2
    What code are you using that actually generates this error? – Adrian Larson Jan 10 at 15:42
  • Would you please include the apex:page declaration from your Visualforce page? You seem to have declared the controller there as if this class were a standard controller rather than an extension. – David Reed Jan 10 at 15:43
  • Please edit your post with any clarifications. That's not what comments are for. – Adrian Larson Jan 10 at 16:44
  • Your page should not be throwing this error. Are you getting it in a unit test? – Adrian Larson Jan 10 at 17:02
  • I have not got to the testing part yet. It is showing up at dev console. Is it ok to write a soql statement from a different custom object (contingency__c) in controller while I do not have it in VF page? – Nikhil Prashar Jan 10 at 18:04
3

Based on your current code snippet, this should not even compile.

<apex:page showHeader="False" controller="Billing_Change_form__c" extensions="customMutliSelectLookUpCntrl">

The controller attribute expects a custom Apex Class whereas you have currently mentioned the name of the custom object, and thus it would give you an error. You are using Billing_Change_form__c in the controller attribute here incorrectly and that you seem to utilize the standardController instead.

For this to work, you should change your VF page to associate to the standardController for the object as below:

<apex:page showHeader="false" standardController="Billing_Change_form__c" extensions="customMutliSelectLookUpCntrl">
  • Thanks for the fix! Now if I want to pull data from a different custom object. Will I be able to do that? – Nikhil Prashar Jan 10 at 18:48
  • Yes you can. But anything around that will classify as a different question altogether. I will recommend you should go through some trailheads and developer guide for VF page and data access using custom controllers/extensions. – Jayant Das Jan 10 at 18:50
  • Thank you so much! – Nikhil Prashar Jan 10 at 18:58
1

Is it because you are passing in the standard controller to the controller extension constructor but defining it on the page as an extension of your custom controller?

Instead of passing in the standard controller pass in the custom controller.

If your custom controller is called 'billing_change_form__c' pass that in:

public customMutliSelectLookUpCntrl(Billing_Change_form__c controller)

Or if you want to use a standardController use the standard controller for the object you need:

<apex:page standardController="account" extensions="customMutliSelectLookUpCntrl">

  • This is my first apex class. I am new to this. Billing_Change_form__c is a custom object which i believe qualifies for standard controller. customMutliSelectLookUpCntrl is the extension I am building. I am trying to add a button on field on Billing_Change_form__c which will open this VF page. – Nikhil Prashar Jan 10 at 16:46
  • Ah ok - so does it work if you do standardController="billing_change_form__c" ? – McH2000 Jan 10 at 16:54
  • No. It will not showup as an option on page layout for that object. – Nikhil Prashar Jan 10 at 16:57
0

There was a mistake on my VF page declaration

<apex:page showHeader="False" **standard**controller="Billing_Change_form__c" extensions="customMutliSelectLookUpCntrl">
  • 3
    You should accept the answer posted by Jayant instead of posting your own answer as your comment on his post shows that he is clearly the one who gave you the answer you needed. – gNerb Jan 10 at 19:55

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.