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
shravani milshravani mil 

FIELD_INTEGRITY_EXCEPTION, Converted Account empty for a Converted Lead.: [ConvertedAccountId]

static testMethod void mytestclass()   
{     
Account a = new Account();     
a.Name = 'Test Account';         
insert a;   
Lead le=new Lead(Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy',Vendor_Business_Contact__c='ass', Contact_Phone__c=111);     
insert le;  [error]   
List<Id> idList = new List<Id>();   
 idList.add(le.Id);     System.debug(idList);   
Database.LeadConvert[] leadsToConvert = new Database.LeadConvert[0];       
 Database.LeadConvert converter = new Database.LeadConvert();         
for (Id l : idList )
{             
converter.setLeadId(l);                //converter.setLeadId(l.id);                System.debug(1);               
account account = new account(name='test');               
insert account;               
converter.setAccountId(account.id);               
contact contact = new contact(firstname='test', lastname='test', accountid=account.id);               
insert contact;               
converter.setContactId(contact.id);                //converter.setOwnerId('00570000000oflK');                converter.setConvertedStatus('Closed - Converted');               
converter.setDoNotCreateOpportunity( true );               
leadsToConvert.add( converter );         
}       
 Database.ConvertLead( leadsToConvert, true );            
}    
}