function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amit Jadhav 13Amit Jadhav 13 

Error: costsheet Compile Error: Constructor not defined: [cost sheet.Wrapper].<Constructor>(Opportunity, Order) at line 17 column 45

This is Apex Class
public with sharing class costsheet {
 
 public costsheet(ApexPages.StandardController controller) {

    }

 public List<Order> ordwrap = new List<Order>();
 public List<Opportunity> oppwrap = new List<Opportunity>();
 
 
 
 public costsheet()
 {
  this.SOWrappers = new List<SOWrapper>();
  ordwrap=[Select id,Cost_Price_As_per_Allocation__r.CI__c from Order];
  oppwrap=[select Id,name,Account.Name from opportunity];
  for(opportunity opp:oppwrap){
                for(Order ord: ordwrap){
                    If(opp.id == ord.id)
                    {
                        SOWrapper wrapper = new SOWrapper(opp, ord);
                        this.SOWrappers.add(wrapper);
                    }
                        
                    }
                }
 }
 public List<SOWrapper> SOWrappers{get;set;}
 public class SOWrapper{
        public Order order{get;set;}
        public Opportunity opportunity{get;set;}
        public Cost_Price__c costprice{get;set;}
        
        public SOWrapper(Order ord, Opportunity opp,Cost_Price__c cp){
            order= ord;
            opportunity = opp;
            costprice = cp;
        }
    }
    
}
Best Answer chosen by Amit Jadhav 13
Raj VakatiRaj Vakati
Change like below and use this code .. you have three argument constructor and you are not using correctly

the constructor  will accept the Order, Opportunity and Cost Price objects 
 
public with sharing class costsheet {
 
 public costsheet(ApexPages.StandardController controller) {

    }

 public List<Order> ordwrap = new List<Order>();
 public List<Opportunity> oppwrap = new List<Opportunity>();
 
 
 
 public costsheet()
 {
  this.SOWrappers = new List<SOWrapper>();
  ordwrap=[Select id,Cost_Price_As_per_Allocation__r.CI__c from Order];
  oppwrap=[select Id,name,Account.Name from opportunity];
  for(opportunity opp:oppwrap){
                for(Order ord: ordwrap){
                    If(opp.id == ord.id)
                    {
                        SOWrapper wrapper = new SOWrapper(ord ,opp ,opp.Cost_Price_As_per_Allocation__r );
                        this.SOWrappers.add(wrapper);
                    }
                        
                    }
                }
 }
 public List<SOWrapper> SOWrappers{get;set;}
 public class SOWrapper{
        public Order order{get;set;}
        public Opportunity opportunity{get;set;}
        public Cost_Price__c costprice{get;set;}
        
        public SOWrapper(Order ord, Opportunity opp,Cost_Price__c cp){
            order= ord;
            opportunity = opp;
            costprice = cp;
        }
    }
    
}