• Tanner
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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.

The documentation states that ConvertLead is untested in the Flex API, but I'd like to confirm that it doesn’t work.  I’m getting an error message: “Invalid Lead ID” when I attempt to use it.  I’ve tried with 15 and 18 character IDs and verified that every ID being passed (account, contact, lead, owner) are all valid.  The Ids themselves are pulled directly from SFDC via the API using the same session the browser.   I’ve verified the whole process by stepping through it in the Flex debugger but without digging through the Flex API source directly I’m not sure what the issue is.

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,

  • January 29, 2008
  • Like
  • 0