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
Iqra TechIqra Tech 

unable to solve this error

etting error : - Constructor not defined: need help
public class My_2nd_Api {
    
    Public static void Insert_Records(){
   
        
List<Opportunity> oppbatch=[select id,name,stageName,Edition__r.name,Sub_Allocation_Name__r.name,Account.name,Account.Website,Account.BillingCountry,Account.BillingState,Account.BillingCity,Account.BillingStreet,Account.BillingPostalcode,(select Unique_id__c,Product_Sub_Category_New__c,stand_Number_s__c,Hall_s__c,Type_of_Stand__c,Stand_Depth__c,Stand_Width__c,
                             Contractual_Sq_M__c,    Exhibitor_Id__c,Open_Sides__c from OpportunityLineItems),          (Select contact.firstname,contact.lastname,contact.Email,contact.Phone,contact.Salutation  from OpportunityContactRoles) 
                           from Opportunity  limit  10];

        system.debug('oppbatch List query.. '+oppbatch);
        
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(Opportunity opp : oppbatch) 
{
 system.debug('Chehking'+opp.OpportunityLineItems);
 OppWrapper oppwrappervar= new OppWrapper(opp.id,opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,opp.Account.name,opp.Account.Website,                                         opp.Account.BillingCountry,opp.Account.BillingState,opp.Account.BillingCity,opp.Account.BillingStreet,                                         opp.Account.BillingPostalcode); 

   
    for(OpportunityLineItem li : opp.OpportunityLineItems)
    {    
        oppwrappervar(li.Unique_id__c,li.Product_Sub_Category_New__c,li.Stand_Number_s__c,li.Hall_s__c,li.Type_of_Stand__c,li.Stand_Depth__c,li.Stand_Width__c,li.Contractual_Sq_M__c);
    }
   for(OpportunityContactRole ocr : opp.OpportunityContactRoles)
    {
       oppwrappervar(ocr.contact.firstname,ocr.contact.lastname,ocr.contact.Email,ocr.contact.Phone,ocr.contact.Salutation);
        
    }
    
  oppWrapperVarList.add(oppwrappervar);
//OppWrapper oppwrappervar=new OppWrapper(oppbtch.Edition_Name__c,oppbtch.Opportunity_Id__c,oppbtch.Opportunity_Name__c,oppbtch.Opportunity_Stage__c,oppbtch.Stand_No__c,oppbtch.Banner_name__c);
//oppWrapperVarList.add(oppwrappervar);
}
 string jsonbody=Json.serialize(oppWrapperVarList);
        system.debug('Json body---->'+jsonbody);
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        //request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
        request.setEndpoint('http://sfdata.iqratechnology.com/api/sf_data');

        request.setMethod('POST');
        request.setHeader('Content-Type','application/json');
        //request.setHeader('Content-Type','multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
        //request.setHeader('Authorization','Bearer '+ AuthorizationToken);
//request.setBody('[{ "RecordId": "456","RecordName": "moosa traders pvt ltd / The Big 5 Construct Egypt 2018 /  / 093061123", "EventName": "a2JD0000001ns6uMAA U", "RecordStage": "Test Stage Amjad","BannerName": "Test Banner Amjad","StandNo": "Test Stand Amjad"}]');
        request.setBody(jsonbody);
        
       HttpResponse response = http.send(request);
        system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
        
        
    }
    
    public class OppWrapper
    {
        public String SFDC_RecordID {get;set;}
        public String SFDC_RecordName {get;set;}
        public String SFDC_RecordStage {get;set;}
        public String SFDC_EventName {get;set;}
        public String Stan_Sub_Allocation_Name {get;set;}
        public String Acount_Long_Name {get;set;}
        public String Web_Site {get;set;}
        public String Country {get;set;}
        public String Country_State {get;set;}
        public String City {get;set;}
        public String Street {get;set;}
        public String Post_code {get;set;}
        public String SFDC_Record_Unique_ID {get;set;}
        public String Product_Subcategory {get;set;}
        public String Stand_no {get;set;}
        public String Hall {get;set;}
        public String Type_of_Stand {get;set;}
        public Decimal Height {get;set;}
        public Decimal Width {get;set;}
        public Decimal Contractual_Sq_M {get;set;}
        public String First_Name {get;set;}
        public String Last_Name {get;set;}
        public String Email {get;set;}
        public String Mobile {get;set;}
        public String Salutation {get;set;}
        
        public OppWrapper(String SFDC_RecordID,String SFDC_RecordName,String SFDC_RecordStage,String SFDC_EventName,String Stan_Sub_Allocation_Name,
                          String Acount_Long_Name,String Web_Site,String Country,String Country_State,String City,String Street,String Post_code,
                          String SFDC_Record_Unique_ID,String Product_Subcategory,String Stand_no,String Hall,String Type_of_Stand,Decimal Height,
                          Decimal Width,Decimal Contractual_Sq_M,String First_Name,String Last_Name,String Email,String Mobile,String Salutation)
        {
            this.SFDC_RecordID =SFDC_RecordID;
            this.SFDC_RecordName =SFDC_RecordName;
            this.SFDC_RecordStage =SFDC_RecordStage;
            this.SFDC_EventName=SFDC_EventName;
            this.Stan_Sub_Allocation_Name=Stan_Sub_Allocation_Name;
            this.Acount_Long_Name=Acount_Long_Name;
            this.Web_Site=Web_Site;
            this.Country=Country;
            this.Country_State=Country_State;
            this.City=City;
            this.Street=Street;
            this.Post_code=Post_code;
            this.SFDC_Record_Unique_ID=SFDC_Record_Unique_ID;
            this.Product_Subcategory=Product_Subcategory;
            this.Stand_no=Stand_no;
            this.Hall=Hall;
            this.Type_of_Stand=Type_of_Stand;
            this.Height=Height;
            this.Width=Width;
            this.Contractual_Sq_M=Contractual_Sq_M;
            
            
            
        }
    }
    
}

Getting error on bold line error is :-

Line 17: Constructor not defined: [My_2nd_Api.OppWrapper].<Constructor>(String, String, String, String, String, String, String, String, String, String, String)
Line 24 Method does not exist or incorrect signature: void oppwrappervar(String, String, String, String, Id, Decimal, Decimal, Decimal) from the type My_2nd_Api
Line 29 : Method does not exist or incorrect signature: void oppwrappervar(String, String, String, String, String) from the type My_2nd_Api

Can anyone please help me to solve this error it is urgent 
Best Answer chosen by Iqra Tech
Adarsh Sharma 4Adarsh Sharma 4
Hi Iqra Tech,

Replace line number 17 with following code and try again.
 
OppWrapper oppwrappervar = new OppWrapper(opp.id,opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,opp.Account.name,opp.Account.Website,opp.Account.BillingCountry,opp.Account.BillingState,opp.Account.BillingCity,opp.Account.BillingStreet,opp.Account.BillingPostalcode, null, null, null, null, null, null, null, null, null, null, null, null, null);

Thanks,
 

All Answers

Anant KamatAnant Kamat
You have defined only one constructor in OppWrapper which is accepting all the variables which is not the case with Line 17. Also in the highlighted lines ( Line 24 and Line 29 ) you cannot put as below
oppwrappervar(ocr.contact.firstname, ocr.contact.lastname, ocr.contact.Email, ocr.contact.Phone, ocr.contact.Salutation);

instead put it as 
oppwrappervar.First_Name = ocr.contact.firstname;

and so on.

Try this and let me know if it works.


 
Iqra TechIqra Tech
@Anant Kamat thnks it is working perfctly for  line 24 & line 29 errro
but i am still getting error on line 17 can you please look into that
Iqra TechIqra Tech
public class My_2nd_Api {
    
    Public static void Insert_Records(){
   
        
List<Opportunity> oppbatch=[select id,name,stageName,Edition__r.name,Sub_Allocation_Name__r.name,Account.name,Account.Website,Account.BillingCountry,Account.BillingState,Account.BillingCity,Account.BillingStreet,Account.BillingPostalcode,
                            (select Unique_id__c,Product_Sub_Category_New__c,stand_Number_s__c,Hall_s__c,Type_of_Stand__c,Stand_Depth__c,Stand_Width__c,
                             Contractual_Sq_M__c,    Exhibitor_Id__c,Open_Sides__c from OpportunityLineItems), 
                            (Select contact.firstname,contact.lastname,contact.Email,contact.Phone,contact.Salutation  from OpportunityContactRoles) 
                           from Opportunity where Edition__r.name ='FM EXPO 2017' AND  HasOpportunityLineItem = true ];
        system.debug('oppbatch List query.. '+oppbatch);
        
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(Opportunity opp : oppbatch) 
{
 system.debug('Chehking'+opp.OpportunityLineItems);
 OppWrapper oppwrappervar= new OppWrapper(opp.id,opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,opp.Account.name,opp.Account.Website,
                                         opp.Account.BillingCountry,opp.Account.BillingState,opp.Account.BillingCity,opp.Account.BillingStreet,
                                         opp.Account.BillingPostalcode); 


     
    for(OpportunityLineItem li : opp.OpportunityLineItems)
    {    
        oppwrappervar.SFDC_Record_Unique_ID=li.Unique_id__c;
        oppwrappervar.Product_Subcategory=li.Product_Sub_Category_New__c;
        oppwrappervar.Stand_no=li.Stand_Number_s__c;
        oppwrappervar.Hall=li.Hall_s__c;
        oppwrappervar.Type_of_Stand=li.Type_of_Stand__c;
        oppwrappervar.Height=li.Stand_Depth__c;
        oppwrappervar.Width=li.Stand_Width__c;
        oppwrappervar.Contractual_Sq_M=li.Contractual_Sq_M__c;
        //oppwrappervar(li.Unique_id__c,li.Product_Sub_Category_New__c,li.Stand_Number_s__c,li.Hall_s__c,li.Type_of_Stand__c,li.Stand_Depth__c,
                       //li.Stand_Width__c,li.Contractual_Sq_M__c);
    }
   for(OpportunityContactRole ocr : opp.OpportunityContactRoles)
    {
        oppwrappervar.First_Name = ocr.contact.firstname;
        oppwrappervar.Salutation =ocr.contact.lastname ;
        oppwrappervar.Email=ocr.contact.Email;
        oppwrappervar.Mobile=ocr.contact.Phone;
        oppwrappervar.Salutation=ocr.contact.Salutation ;

       //oppwrappervar(ocr.contact.firstname,ocr.contact.lastname,ocr.contact.Email,ocr.contact.Phone,ocr.contact.Salutation);
        
    }
    
//oppWrapperVarList.add(oppwrappervar);
//OppWrapper oppwrappervar=new OppWrapper(oppbtch.Edition_Name__c,oppbtch.Opportunity_Id__c,oppbtch.Opportunity_Name__c,oppbtch.Opportunity_Stage__c,oppbtch.Stand_No__c,oppbtch.Banner_name__c);
//oppWrapperVarList.add(oppwrappervar);
}
 string jsonbody=Json.serialize(oppWrapperVarList);
        system.debug('Json body---->'+jsonbody);
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        //request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
        request.setEndpoint('http://sfdata.iqratechnology.com/api/sf_data');

        request.setMethod('POST');
        request.setHeader('Content-Type','application/json');
        //request.setHeader('Content-Type','multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
        //request.setHeader('Authorization','Bearer '+ AuthorizationToken);
//request.setBody('[{ "RecordId": "456","RecordName": "moosa traders pvt ltd / The Big 5 Construct Egypt 2018 /  / 093061123", "EventName": "a2JD0000001ns6uMAA U", "RecordStage": "Test Stage Amjad","BannerName": "Test Banner Amjad","StandNo": "Test Stand Amjad"}]');
        request.setBody(jsonbody);
        
       HttpResponse response = http.send(request);
        system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
        
        
    }
    
    public class OppWrapper
    {
        public String SFDC_RecordID {get;set;}
        public String SFDC_RecordName {get;set;}
        public String SFDC_RecordStage {get;set;}
        public String SFDC_EventName {get;set;}
        public String Stan_Sub_Allocation_Name {get;set;}
        public String Acount_Long_Name {get;set;}
        public String Web_Site {get;set;}
        public String Country {get;set;}
        public String Country_State {get;set;}
        public String City {get;set;}
        public String Street {get;set;}
        public String Post_code {get;set;}
        public String SFDC_Record_Unique_ID {get;set;}
        public String Product_Subcategory {get;set;}
        public String Stand_no {get;set;}
        public String Hall {get;set;}
        public String Type_of_Stand {get;set;}
        public Decimal Height {get;set;}
        public Decimal Width {get;set;}
        public Decimal Contractual_Sq_M {get;set;}
        public String First_Name {get;set;}
        public String Last_Name {get;set;}
        public String Email {get;set;}
        public String Mobile {get;set;}
        public String Salutation {get;set;}
        
        public OppWrapper(String SFDC_RecordID,String SFDC_RecordName,String SFDC_RecordStage,String SFDC_EventName,String Stan_Sub_Allocation_Name,
                          String Acount_Long_Name,String Web_Site,String Country,String Country_State,String City,String Street,String Post_code,
                          String SFDC_Record_Unique_ID,String Product_Subcategory,String Stand_no,String Hall,String Type_of_Stand,Decimal Height,
                          Decimal Width,Decimal Contractual_Sq_M,String First_Name,String Last_Name,String Email,String Mobile,String Salutation)
        {
            this.SFDC_RecordID =SFDC_RecordID;
            this.SFDC_RecordName =SFDC_RecordName;
            this.SFDC_RecordStage =SFDC_RecordStage;
            this.SFDC_EventName=SFDC_EventName;
            this.Stan_Sub_Allocation_Name=Stan_Sub_Allocation_Name;
            this.Acount_Long_Name=Acount_Long_Name;
            this.Web_Site=Web_Site;
            this.Country=Country;
            this.Country_State=Country_State;
            this.City=City;
            this.Street=Street;
            this.Post_code=Post_code;
            this.SFDC_Record_Unique_ID=SFDC_Record_Unique_ID;
            this.Product_Subcategory=Product_Subcategory;
            this.Stand_no=Stand_no;
            this.Hall=Hall;
            this.Type_of_Stand=Type_of_Stand;
            this.Height=Height;
            this.Width=Width;
            this.Contractual_Sq_M=Contractual_Sq_M;
            
            
            
        }
    }
    
}


Line no 17 Constructor not defined: [My_2nd_Api.OppWrapper].<Constructor>(Id, String, String, String, String, String, String, String, String, String, String, String)

i have bold that line on which i am getting error
Adarsh Sharma 4Adarsh Sharma 4
Hi Iqra Tech,

Replace line number 17 with following code and try again.
 
OppWrapper oppwrappervar = new OppWrapper(opp.id,opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,opp.Account.name,opp.Account.Website,opp.Account.BillingCountry,opp.Account.BillingState,opp.Account.BillingCity,opp.Account.BillingStreet,opp.Account.BillingPostalcode, null, null, null, null, null, null, null, null, null, null, null, null, null);

Thanks,
 
This was selected as the best answer
Iqra TechIqra Tech

sir it is woorking now i am just getting this error :-
Unexpected token 'public'. on Line no 77

public class My_2nd_Api {
    
    Public static void Insert_Records(){
   
        
List<Opportunity> oppbatch=[select id,name,stageName,Edition__r.name,Sub_Allocation_Name__r.name,Account.name,Account.Website,Account.BillingCountry,Account.BillingState,Account.BillingCity,Account.BillingStreet,Account.BillingPostalcode,Account.Banner_Name__c,
                            (select Unique_id__c,Product_Sub_Category_New__c,stand_Number_s__c,Hall_s__c,Type_of_Stand__c,Stand_Depth__c,Stand_Width__c,
                             Contractual_Sq_M__c,    Exhibitor_Id__c,Open_Sides__c from OpportunityLineItems), 
                            (Select contact.firstname,contact.lastname,contact.Email,contact.Phone,contact.Salutation  from OpportunityContactRoles) 
                           from Opportunity where Edition__r.name ='FM EXPO 2017' AND  HasOpportunityLineItem = true  limit 10];
        system.debug('oppbatch List query.. '+oppbatch);
        
List<OppWrapper> oppWrapperVarList = new List<OppWrapper>();
for(Opportunity opp : oppbatch) 
{
 system.debug('Chehking'+opp.OpportunityLineItems);
 OppWrapper oppwrappervar = new OppWrapper(opp.id,opp.name,opp.StageName,opp.Edition__r.name,opp.Sub_Allocation_Name__r.name,
                                           opp.Account.name,opp.Account.Website,opp.Account.BillingCountry,opp.Account.BillingState,
                                           opp.Account.BillingCity,opp.Account.BillingStreet,opp.Account.BillingPostalcode,opp.Account.Banner_Name__c, 
                                            null, null, null, null, null, null, null, null, null, null, null, null, null); 

     
    for(OpportunityLineItem li : opp.OpportunityLineItems)
    {    
        oppwrappervar.SFDC_Record_Unique_ID=li.Unique_id__c;
        oppwrappervar.Product_Subcategory=li.Product_Sub_Category_New__c;
        oppwrappervar.Stand_no=li.Stand_Number_s__c;
        oppwrappervar.Hall=li.Hall_s__c;
        oppwrappervar.Type_of_Stand=li.Type_of_Stand__c;
        oppwrappervar.Height=li.Stand_Depth__c;
        oppwrappervar.Width=li.Stand_Width__c;
        oppwrappervar.Contractual_Sq_M=li.Contractual_Sq_M__c;
        //oppwrappervar(li.Unique_id__c,li.Product_Sub_Category_New__c,li.Stand_Number_s__c,li.Hall_s__c,li.Type_of_Stand__c,li.Stand_Depth__c,
                       //li.Stand_Width__c,li.Contractual_Sq_M__c);
    }
   for(OpportunityContactRole ocr : opp.OpportunityContactRoles)
    {
        oppwrappervar.First_Name = ocr.contact.firstname;
        oppwrappervar.Salutation =ocr.contact.lastname ;
        oppwrappervar.Email=ocr.contact.Email;
        oppwrappervar.Mobile=ocr.contact.Phone;
        oppwrappervar.Salutation=ocr.contact.Salutation ;

       //oppwrappervar(ocr.contact.firstname,ocr.contact.lastname,ocr.contact.Email,ocr.contact.Phone,ocr.contact.Salutation);
        
    }
    
oppWrapperVarList.add(oppwrappervar);

 string jsonbody=Json.serialize(oppWrapperVarList);
        system.debug('Json body---->'+jsonbody);
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        //request.setEndpoint('http://fpdatamap.salesforceoutsourcing.in/api/FPDatas');
        request.setEndpoint('http://sfdata.iqratechnology.com/api/fs_metadeta');

        request.setMethod('POST');
        request.setHeader('Content-Type','application/json');
        //request.setHeader('Content-Type','multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW');
        //request.setHeader('Authorization','Bearer '+ AuthorizationToken);
//request.setBody('[{ "RecordId": "456","RecordName": "moosa traders pvt ltd / The Big 5 Construct Egypt 2018 /  / 093061123", "EventName": "a2JD0000001ns6uMAA U", "RecordStage": "Test Stage Amjad","BannerName": "Test Banner Amjad","StandNo": "Test Stand Amjad"}]');
        request.setBody(jsonbody);
        
       HttpResponse response = http.send(request);
        system.debug('Response body '+ response.getBody());
if (response.getStatusCode() != 201) {
    System.debug('The status code returned was not expected: ' +
        response.getStatusCode() + ' ' + response.getStatus());
} else {
    System.debug(response.getBody());
}
        
        
    }
    
    public class OppWrapper// error :-  Unexpected token 'public'.
    {
        public String SFDC_RecordID {get;set;}
        public String SFDC_RecordName {get;set;}
        public String SFDC_RecordStage {get;set;}
        public String SFDC_EventName {get;set;}
        public String Stan_Sub_Allocation_Name {get;set;}
        public String Acount_Long_Name {get;set;}
        public String Web_Site {get;set;}
        public String Country {get;set;}
        public String Country_State {get;set;}
        public String City {get;set;}
        public String Street {get;set;}
        public String Post_code {get;set;}
        public String SFDC_Record_Unique_ID {get;set;}
        public String Product_Subcategory {get;set;}
        public String Stand_no {get;set;}
        public String Hall {get;set;}
        public String Type_of_Stand {get;set;}
        public Decimal Height {get;set;}
        public Decimal Width {get;set;}
        public Decimal Contractual_Sq_M {get;set;}
        public String First_Name {get;set;}
        public String Last_Name {get;set;}
        public String Email {get;set;}
        public String Mobile {get;set;}
        public String Salutation {get;set;}
        public String Banner_Name {get;set;}
        
        public OppWrapper(String SFDC_RecordID,String SFDC_RecordName,String SFDC_RecordStage,String SFDC_EventName,String Stan_Sub_Allocation_Name,
                          String Acount_Long_Name,String Web_Site,String Country,String Country_State,String City,String Street,String Post_code,
                          String SFDC_Record_Unique_ID,String Product_Subcategory,String Stand_no,String Hall,String Type_of_Stand,Decimal Height,
                          Decimal Width,Decimal Contractual_Sq_M,String First_Name,String Last_Name,String Email,String Mobile,String Salutation,String Banner_Name)
        {
            this.SFDC_RecordID =SFDC_RecordID;
            this.SFDC_RecordName =SFDC_RecordName;
            this.SFDC_RecordStage =SFDC_RecordStage;
            this.SFDC_EventName=SFDC_EventName;
            this.Stan_Sub_Allocation_Name=Stan_Sub_Allocation_Name;
            this.Acount_Long_Name=Acount_Long_Name;
            this.Web_Site=Web_Site;
            this.Country=Country;
            this.Country_State=Country_State;
            this.City=City;
            this.Street=Street;
            this.Post_code=Post_code;
            this.SFDC_Record_Unique_ID=SFDC_Record_Unique_ID;
            this.Product_Subcategory=Product_Subcategory;
            this.Stand_no=Stand_no;
            this.Hall=Hall;
            this.Type_of_Stand=Type_of_Stand;
            this.Height=Height;
            this.Width=Width;
            this.Contractual_Sq_M=Contractual_Sq_M;
            this.Banner_Name=Banner_Name;
            
            
        }
    }
    
}

Iqra TechIqra Tech
got it solve that error i missed one curly brases error sort out now i need to convert this class into the batch class can it be possible?
Iqra TechIqra Tech
Hi @Adarsh Sharma 4
i need you are you avialbe now ????
Iqra TechIqra Tech
Hi @Adarsh Sharma 4

U there i need one more favor from you