MrTechie
MrTechie

Reputation: 1847

SOAP-ERROR: When using Enterprise Client for SalesForce

I am attempting to pass a custom field via a SOAP Client to SalesForce, here's my existing code:

        try {
          $mySforceConnection = new SforceEnterpriseClient();
          $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
          $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

          $leadConvert = new stdClass;
          $leadConvert->leadId = $eLEADID;
          $leadConvert->Custome_field = true;

          $leadConvertArray = array($leadConvert);

          echo "<pre>";
          print_r($leadConvertArray);
          echo "</pre>";

          $leadConvertResponse = $mySforceConnection->convertLead($leadConvertArray);

          echo "<pre>";
          print_r($leadConvertResponse);
          echo "</pre>";


        } 
        catch (Exception $e) {
          echo $e->faultstring;
        }

The way it's being passed to SOAP is this:

    Array
    (
        [0] => stdClass Object
            (
                [leadId] => XXXXXXXXXX
                [Custom_field] => 1
            )

    )

And my error that I am getting is as follows:

SOAP-ERROR: Encoding: object has no 'convertedStatus' property

Do I have to set something in the WSDL in order for this to work? This is to attempt to update a leadID in SalesForce to have it be converted to account/opportunity.

Is there a better way for me to debug this and see what I am missing maybe from the WSDL?

Note: the error means that you "literally" don't have the parameter set in the request. To fix it, simply pass what it's complaining about.

New Issue:

After adding the request, I am getting the following error:

Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location

Not quite sure what that error means at all. Any thoughts?

Upvotes: 1

Views: 221

Answers (1)

Daniel Ballinger
Daniel Ballinger

Reputation: 13537

For the error:

Element {urn:enterprise.soap.sforce.com}Custome_field invalid at this location

It appears you are trying to set a custom field on the Lead record to a boolean value.

Custom fields in Salesforce will typically end with the __c suffix.

Check the API name for the field in Salesforce and ensure the user who generated and is accessing the Enterprise API has field level access to it.

Then you code should be something like:

$leadConvert->Custom_field__c = true;

It also seems a bit odd that you are setting a custom field for a Lead and then passing it to the convertLead() web method. See the LeadConvert Arguments, which include convertedStatus.

Upvotes: 1

Related Questions