+ Start a Discussion
Akshay Vasu 1Akshay Vasu 1 

constructor not defined error when null is sent as an argument value of the Datatype Date to the wrapper class Constructor

I have created a wrapper class to create an Object and send it as a request to a third party system. It was working well. But after I added a two new arguments of the Datatype Date, I am getting the below error.

    Constructor not defined: [SFDC_DataObject.CustomerAccountObject].<Constructor>(Id, String, Id, String, Id, String, Integer, NULL, String, String, Id, String, NULL, String, String, String, String)

The request that I am creating and sending is as below.

    SFDC_DataObject.CustomerAccountObject cusAccObj = new SFDC_DataObject.CustomerAccountObject(o.AccountId, o.Customer_Name__c, o.Agency_Name__r.Id,o.Agency_Name_OB__c, o.Opportunity.OwnerId, o.Opportunity.Owner.FederationIdentifier, PrimarySalesSplitPercent, null, secSOSalesforceId.get(o.OpportunityId), secSOSalesforceEmail.get(o.OpportunityId), o.Opportunity.Customer_Success_Manage__r.Id, o.Opportunity.Customer_Success_Manage__r.FederationIdentifier, null, o.Billing_Email__c, o.Billing_Phone__c, o.Bill_To_Name__c, o.Billing_Notes__c);

My wrapper class for the same object is as below.

    public class CustomerAccountObject {
            public String  sfCustomerId;
            public String  customerName;
            public String  sfAgencyId;
            public String  agencyName;
            public String  sfPrimarySalesOwnerId;
            public String  primarySalesOwnerEmail;
            public Integer primarySalesOwnerPercentage;
            public Date    primarySalesOwnerEffectiveFrom;
            public String  sfSecondarySalesOwnerId;
            public String  secondarySalesOwnerEmail;
            public Date    secondarySalesOwnerEffectiveFrom;
            public String  sfAccountManagerId;
            public String  accountManagerEmail;
            public String  billingEmail;
            public String  billingPhone;
            public String  billingName;
            public String  billingNotes;
    
            public CustomerAccountObject() {}
    
            public CustomerAccountObject(String sfCustomerId, String customerName, String sfAgencyId, String agencyName, String sfPrimarySalesOwnerId, String primarySalesOwnerEmail, Integer primarySalesOwnerPercentage, Date primarySalesOwnerEffectiveFrom, String sfSecondarySalesOwnerId, String secondarySalesOwnerEmail, Date secondarySalesOwnerEffectiveFrom, String sfAccountManagerId, String accountManagerEmail, String billingEmail, String billingPhone, String billingName, String billingNotes) {
                this.sfCustomerId                     = sfCustomerId;
                this.customerName                     = customerName;
                this.sfAgencyId                       = sfAgencyId;
                this.agencyName                       = agencyName;
                this.sfPrimarySalesOwnerId            = sfPrimarySalesOwnerId;
                this.primarySalesOwnerEmail           = primarySalesOwnerEmail;
                this.primarySalesOwnerPercentage      = primarySalesOwnerPercentage;
                this.primarySalesOwnerEffectiveFrom   = primarySalesOwnerEffectiveFrom;
                this.sfSecondarySalesOwnerId          = sfSecondarySalesOwnerId;
                this.secondarySalesOwnerEmail         = secondarySalesOwnerEmail;
                this.secondarySalesOwnerEffectiveFrom = secondarySalesOwnerEffectiveFrom;
                this.sfAccountManagerId               = sfAccountManagerId;
                this.accountManagerEmail              = accountManagerEmail;
                this.billingEmail                     = billingEmail;
                this.billingPhone                     = billingPhone;
                this.billingName                      = billingName;
                this.billingNotes                     = billingNotes;
            }
        }

I began getting the error after I added the null for the Date arguments I.e primarySalesOwnerEffectiveFrom and **secondarySalesOwnerEffectiveFrom** during the Object creation.

Can anyone please let me know what am I doing wrong here.
Best Answer chosen by Akshay Vasu 1
chanchal_:)chanchal_:)
you should always pass paratmeters in order only. 

you are not passing null to date. 
'secondarySalesOwnerEffectiveFrom'  is your last 7th parameter and you are passing null to last 5th parameter. 





SFDC_DataObject.CustomerAccountObject cusAccObj = new SFDC_DataObject.CustomerAccountObject(o.AccountId, o.Customer_Name__c, o.Agency_Name__r.Id,o.Agency_Name_OB__c, o.Opportunity.OwnerId, o.Opportunity.Owner.FederationIdentifier, PrimarySalesSplitPercent, null, secSOSalesforceId.get(o.OpportunityId), secSOSalesforceEmail.get(o.OpportunityId), null, o.Opportunity.Customer_Success_Manage__r.Id, o.Opportunity.Customer_Success_Manage__r.FederationIdentifier, o.Billing_Email__c, o.Billing_Phone__c, o.Bill_To_Name__c, o.Billing_Notes__c);


 

All Answers

chanchal_:)chanchal_:)
you should always pass paratmeters in order only. 

you are not passing null to date. 
'secondarySalesOwnerEffectiveFrom'  is your last 7th parameter and you are passing null to last 5th parameter. 





SFDC_DataObject.CustomerAccountObject cusAccObj = new SFDC_DataObject.CustomerAccountObject(o.AccountId, o.Customer_Name__c, o.Agency_Name__r.Id,o.Agency_Name_OB__c, o.Opportunity.OwnerId, o.Opportunity.Owner.FederationIdentifier, PrimarySalesSplitPercent, null, secSOSalesforceId.get(o.OpportunityId), secSOSalesforceEmail.get(o.OpportunityId), null, o.Opportunity.Customer_Success_Manage__r.Id, o.Opportunity.Customer_Success_Manage__r.FederationIdentifier, o.Billing_Email__c, o.Billing_Phone__c, o.Bill_To_Name__c, o.Billing_Notes__c);


 
This was selected as the best answer
Akshay Vasu 1Akshay Vasu 1
I am actually passing Null at 2 places for two different Date arguments. That is "primarySalesOwnerEffectiveFrom" and "secondarySalesOwnerEffectiveFrom" which are in 8th and 13th position in the argument list from the beginning. The one place that you mentioned, I am passing the value for "primarySalesOwnerEffectiveFrom".
Akshay Vasu 1Akshay Vasu 1
@chanchal_:) You were right, there was issue with the Order of the arguments. Thank you.