1

Below is my Apex Class.

public class OptySaleTaxCalcController {

    public List<Account_Address__c> AccountaddressList;
    public AcctSeedERP__Sales_Order__c salesOrder;

    public OptySaleTaxCalcController (ApexPages.StandardController controller) 
    {...}
}

I want to call its constructor from another class. I am trying like below but it errors out. What am I missing?

OptySaleTaxCalcController controller1 = new OptySaleTaxCalcController (new ApexPages.StandardController());

I get this error:

Error: Compile Error: Constructor not defined: [ApexPages.StandardController].() at line 11 column 79

  • What's the error? Your class is called OptySaleTaxCalcController yet you're calling a new Opportunity object? – Dan Jones Feb 27 '17 at 17:41
  • just updated my original question – Maneesh Feb 27 '17 at 17:47
3

You've got it backwards; the opportunity needs to be passed to the standard controller:

ApexPages.StandarController controller = new ApexPages.StandardController(new Opportunity());

From there, pass it to your class:

OptySaleTaxCalcController customController = new OptySaleTaxCalcController(controller);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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