You need to sign in to do that
Don't have an account?
EJW
Thanks,
ConvertLead doesn't work in ApexCode or with the Flex API.
LeadConvert isn’t
considered a valid class in Apex Code. Database.ConvertLead was released
with Winter ’08 but using that call requires you pass in a single LeadConvert
object or an array of LeadConvert objects but the compiler doesn’t recognize
the class. I’ve verified that I’m compiling it using the 11.1 URL.
Here’s sample Flex code that’s failing, along with the error message:
Error:
Message:
valid leadId is required
statusCode:
INVALID_CROSS_REFERENCE_KEY
Code:
private function convertSingleLead( leadId:String, accountId:String, contactId:String, ownerId:String ):void { var converter:LeadConvert = new LeadConvert; converter.accountId = accountId; converter.contactId = contactId; converter.doNotCreateOpportunity = true; converter.overwriteLeadSource = true; converter.convertedStatus = “Closed – Converted”; converter.ownerId = ownerId; converter.leadId = leadId; apex.convertLead( new Array( converter ), new AsyncResponder( postConversion, sfdcCallFailed ) ); }
Thanks,
Yes, I'm seeing the same problem. I checked to make sure I had the latest release of the toolkit - and I do.
The sample code also raises this error.
public void ConvertLead()
{
Database.LeadConvert[] leadsToConvert = new Database.LeadConvert[0];
Database.LeadConvert converter;
converter = new Database.LeadConvert();
converter.setLeadId( <lead id here> );
converter.setAccountId( <account id here> );
converter.setContactId( <contact id here> );
converter.setOwnerId( <owner id here> );
converter.setConvertedStatus( <status here> );
converter.setDoNotCreateOpportunity( true );
leadsToConvert.add( converter );
Database.ConvertLead( leadsToConvert, true );
}
I saw a post from about a year ago about the same issue, and they had a release to the toolkit that was supposed to fix it. But I'm wondering if it broke again, when they sub-classed LeadConvert under Database.
Can someone post a quick update to the Flex Toolkit to get us rolling again???
Regards,
Hi everyone,
I figured out what the problem was. It was based on the assigned rules checkbox being checked and also that the default lead owner was a queue.
Hi everyone,
I am trying to implement the apex lead convertion.Here is what i have done.
I have created Custom List Button, which calls the javacsript
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var records= {!GETRECORDIDS($ObjectType.Lead)};
sforce.apex.execute("tester","ConvertLead",{leads:records});
the code ofr the class is :
global class tester {
WebService static void ConvertLead(Id[] leads){
Database.LeadConvert[] leadsToConvert = new Database.LeadConvert[0];
Database.LeadConvert converter = new Database.LeadConvert();
for (Id l : leads){
converter.setLeadId(l);
//converter.setLeadId(l.id);
System.debug(1);
account account = new account(name='test');
insert account;
System.debug(2);
converter.setAccountId(account.id);
contact contact = new contact(firstname='test', lastname='test', accountid=account.id);
insert contact;
System.debug(3);
converter.setContactId(contact.id);
//converter.setOwnerId('00570000000oflK');
converter.setConvertedStatus('Closed - Converted');
converter.setDoNotCreateOpportunity( true );
leadsToConvert.add( converter );
}
Database.ConvertLead( leadsToConvert, true );
}
public static testMethod void testbasicAuthCallout(){
System.debug('Calling test');
Lead le=new Lead(Email='svreddych@gmail.com', Company='Saksoft',LastName='reddy');
insert le;
List<Id> idList = new List<Id>();
idList.add(le.Id);
System.debug(idList);
tester.ConvertLead(idList);
}
}
But i am getting the following error:
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:'System.DmlException: ConvertLead failed. First exception on row 1; first error: CANNOT_UPDATE_CONVERTED_LEAD, cannot reference converted lead: []
Class.MileageTrack.tester.ConvertLead: line 22, column 4
External entry point', }
Please help me