You need to sign in to do that
Don't have an account?
etechcareers
Constructor not defined: [ProductBreakdown.OpportunityTotal]???
Hi I keep getting this error:
Constructor not defined: [ProductBreakdown.OpportunityTotal].<Constructor>(SOBJECT:OpportunityLineItem)
What is wrong with my code?
public List<OpportunityTotal> getOpportunityTotals() { List<OpportunityTotal> OpportunityTotals = new List<OpportunityTotal>(); for(OpportunityLineItem o:[SELECT Id, TotalPrice, Product_Name__c, Opportunity.Id, Opportunity.Name, Opportunity.StageName, Opportunity.Accountid, Opportunity.Amount FROM OpportunityLineItem Where Opportunity.StageName='Closed Won' And Opportunity.Account.id='001Q000000Js7pP' ]) { OpportunityTotals.add(new OpportunityTotal(o)); } return sortOpportunityTotals(OpportunityTotals); }
Thanks
The error is at this line:
You're creating a new OpportyunityTotal object and passing an OpportunityLineItem into it's constructor. Now, I dont know what OpportyunityTotals is, I'm guessing its the name of a custom object you've created which has a field of OpportunityLineItem type. If I'm right, you need to pass the name of the field when you construct the object.
Lets say your OpportunityLineItem field name on the OpportyunityTotal object is called OLI. You would construct like: