I am using the SalesForce “Beatbox” Library (http://code.google.com/p/salesforce-beatbox/source/browse/trunk/src/beatbox/_beatbox.py)
EXCEPTION 1: When I just send the leadId, I get the exception “INVALID_CROSS_REFERENCE_KEY: valid leadId is required”
This is saying I’m not using a valid leadId, but I swear it’s a valid leadId because I did a retrieve lead beforehand and took the leadId from SalesForce themselves!
EXCEPTION 2:
When I uncomment the convertedStatus and doNotCreateOpportunity parameters, I get the exception “soapenv:Client fault: Element {urn:partner.soap.sforce.com}doNotCreateOpportunity invalid at this location”
This is saying something is wrong with the way I’m passing the parameters to the SalesForce API. It looks correct to me though.
Any ideas on how to resolve these?
def convertLead(self, leadIds, convertedStatus, doNotCreateOpportunity=False):
return ConvertLeadRequest(self.__serverUrl, self.sessionId, leadIds, convertedStatus, doNotCreateOpportunity).post(self.__conn)
class ConvertLeadRequest(AuthenticatedRequest):
"""
Converts a Lead to an Account. See also:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_convertlead.htm
"""
def __init__(self, serverUrl, sessionId, leadIds, convertedStatus, doNotCreateOpportunity=False):
AuthenticatedRequest.__init__(self, serverUrl, sessionId, "convertLead")
self.__convertedStatus = convertedStatus
self.__leadIds = leadIds;
self.__doNotCreateOpportunity = doNotCreateOpportunity
def writeBody(self, s):
#s.writeStringElement(_partnerNs, "convertedStatus", self.__convertedStatus)
#s.writeStringElement(_partnerNs, "doNotCreateOpportunity", self.__doNotCreateOpportunity)
s.writeStringElement(_partnerNs, "leadId", self.__leadIds)
EDIT:
Now, when I make the following request:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:p="urn:partner.soap.sforce.com" xmlns:m="http://soap.sforce.com/2006/04/metadata" xmlns:o="urn:sobject.partner.soap.sforce.com" xmlns:w="http://soap.sforce.com/2006/08/apex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Header>
<p:CallOptions>
<p:client>BeatBox/0.9</p:client>
</p:CallOptions>
<p:SessionHeader>
<p:sessionId>REDACTED</p:sessionId>
</p:SessionHeader>
</s:Header>
<s:Body>
<p:convertLead>
<p:convertedStatus>Cold Qualified</p:convertedStatus>
<p:doNotCreateOpportunity>False</p:doNotCreateOpportunity>
<p:leadId>00QC000000zAbLEMA0</p:leadId>
<p:overwriteLeadSource>False</p:overwriteLeadSource>
<p:sendNotificationEmail>False</p:sendNotificationEmail>
</p:convertLead>
</s:Body>
</s:Envelope>
I still get the exception “converted status is invalid”
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Element {urn:partner.soap.sforce.com}convertedStatus invalid at this location</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
The problem is that writeBody is not generating the correct structure. checking the WSDL shows that the convertLead call is expecting to take 0..n of these structures. (Exception #2 is the hint about this)
so your writeBody needs to be something like
If you want to do bulk lead convert, then you’ll need to generate multiple instance of this structure for each lead conversion you want to do.