1
 public SFA_LeadNewOverride_VFC(ApexPages.StandardController stdController) {
        this.mysObject = (sObject)stdController.getRecord();

        recId = ApexPages.currentPage().getParameters().get(LABEL.SFA_NEW_LEAD_ACC_FIELD_LKID);
        accName = ApexPages.currentPage().getParameters().get(LABEL.SFA_NEW_LEAD_ACC_NAME_ID);

     }   

I am trying this

 Lead leadRecord=new Lead();
                leadRecord.LeadSource='Web';
                leadRecord.Company='TestCompany';
                leadRecord.Status='Owner-Working';
                leadRecord.Rejection_Reason__c='not accepted';
                leadRecord.LastName='Ggg';
                leadRecord.Contact_Email__c='[email protected]';
                leadRecord.Country__c='India';
                leadRecord.Account_Name__c=acc.id;
                leadRecord.Contact__c=con.id;
                leadRecord.Email='[email protected]';
                leadRecord.MobilePhone = '1234567890';
                leadRecord.Phone = '1234567890';
                insert leadRecord;

 ***SFA_LeadNewOverride_VFC objVFC = new SFA_LeadNewOverride_VFC(leadRecord);***

but it gives error in test class that is Compile Error:

Constructor not defined: [SFA_LeadNewOverride_VFC].(Lead) at line 55 column 51

2 Answers 2

1

You need to create a standard controller with the lead record before passing it to your constructor. The constructor takes StandardController type variable and not an SObject. Try doing this:

ApexPages.StandardController leadStandardController = new ApexPages.StandardController(leadRecord);
SFA_LeadNewOverride_VFC objVFC = new SFA_LeadNewOverride_VFC(leadStandardController);
2
  • and what about to standardsetcontroller in constructor Commented Oct 19, 2016 at 6:49
  • public SFA_LeadNewOverride_VFC(ApexPages.StandardSetController controller) { recId = ApexPages.currentPage().getParameters().get('id'); if(String.isNotBlank(recId) && recId.getSObjectType().getDescribe().getName() == 'Account'){ accId = recId; accOnLead = [Select Id,Name FROM Account WHERE Id =:recId LIMIT 1]; } Commented Oct 19, 2016 at 6:49
0

The parameter for the method is a standard controller so you will need to do this:

SFA_LeadNewOverride_VFC objVFC = 
        new SFA_LeadNewOverride_VFC(
          New ApexPages.StandardController(
                leadRecord
           )
        );

Pass in a constructed standard controller

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .