I am converting a lead into Account it is throughing an error:System.DmlException: ConvertLead failed. UNKNOWN_EXCEPTION,Insert failed.REQUIRED_FIELD_MISSING, Required fields are missing: : [CloseDate]
Hi Anoop Yes i am using Apex code to convert lead.code is here below pls suggest solution. I have a trigger which convert a lead if status is qualified ,into account Excetion is at Line 'Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);'
Hi Anoop Yes my trigger is working fine .no problem with it.
i put your code but problem is still there at same line "Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);"
System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloseDate]: [CloseDate]
Are you using any apex code to convert the Lead?.
If yes, This error belongs to opportunity close date.
Yes i am using Apex code to convert lead.code is here below pls suggest solution.
I have a trigger which convert a lead if status is qualified ,into account
Excetion is at Line 'Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);'
static testMethod void testConvertLead() {
// Variables to use in testing
MBA_Staging_Account__c objMBAAcct;
MBA_Staging_Subscription__c objMBASub;
MBA_Staging_Contact__c objMBAContact;
TestDataGenerator td = new TestDataGenerator();
// Initialize the Custom Setting Map
td.getStagingToTableMappingSettings();
// Create Staging Account records as not Paid and grab one of them
objMBAAcct = new MBA_Staging_Account__c();
objMBAAcct.MBAAccountID__c='test1opp7014';
objMBAAcct.CompanyName__c='company7014';
insert objMBAAcct;
// Create Staging Contact records as not Paid
objMBAContact=new MBA_Staging_Contact__c();
objMBAContact.MBAAccountID__c=objMBAAcct.MBAAccountID__c;
objMBAContact.Email__c='test1opp7014@gmail.com';
objMBAContact.MBAClientID__c='clienttest1opp7014';
insert objMBAContact;
// Create Staging Subscription records as paid
objMBASub = new MBA_Staging_Subscription__c();
objMBASub.MBASubscriptionID__c='sub1testopp77014';
objMBASub.MBAAccountID__c = objMBAAcct.MBAAccountID__c;
objMBASub.isTrial__c=true;
objMBASub.SubscriptionType__c ='Store';
insert objMBASub;
//creating a lead for converting it
Lead objlead=new Lead();
objlead.LastName='test1lead2014';
objlead.Company='testcompany';
objlead.Stage__c ='New';
objlead.MBAAccountID__c=objMBAAcct.MBAAccountID__c;
Database.SaveResult saveResults = Database.Insert(objlead);
// Create a LeadConvert instance to be used
Database.LeadConvert leadsToConvert = new Database.LeadConvert();
leadsToConvert.setConvertedStatus('Qualified');
leadsToConvert.setLeadId(saveResults.getId());
// Convert the leads
Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);
// Start Test
test.startTest();
test.stopTest();
}
Is your Trigger working fine?
For Test method,
You should insert a lead, After that change the status to "Qualified" and then update that lead.
Yes my trigger is working fine .no problem with it.
i put your code but problem is still there at same line "Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);"
System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [CloseDate]: [CloseDate]
Database.SaveResult saveResults = Database.Insert(objlead);
// Create a LeadConvert instance to be used
Database.LeadConvert leadsToConvert = new Database.LeadConvert();
leadsToConvert.setConvertedStatus('Qualified');
leadsToConvert.setLeadId(saveResults.getId());
// Convert the leads
Database.LeadConvertResult lcResults = Database.convertLead(leadsToConvert);
When you will update update lead , by default it will call the above method.
You Are right but to fire my trigger i have to insert a lead then convert it.
is that on Lead?
My problem solved .Thanks for help .Thanks A Lot.