2

I create a lead form going through this Customize | Leads | Web-to-Lead.

I want to submit this form through soap api.

I use code given in below link on salesforces developer.

https://developer.salesforce.com/page/PHP_Toolkit_13.0_Create_Delete_Undelete_Sample_(Enterprise)

Code:

define("SOAP_CLIENT_BASEDIR", "soapclient"); 
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
require_once ('userAuth.php');
try {
  $mySforceConnection = new SforceEnterpriseClient();
  $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
  $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);

  $sObject = new stdclass();
  $sObject->first_name = 'Smith';
  $sObject->last_name = 'John';
  $sObject->company = 'hashe';
  $sObject->email = 'anjum@hashehouse.com';
  $sObject->city = 'lahore';
  $sObject->state = 'punjab';
  $sObject->street = 'ts 3 g';
  $sObject->zip = '54400';
  $sObject->country = 'pakistan';
  $sObject->description = 'This is just for testing ';


  echo "**** Creating the following:\r\n"; 
  $createResponse = $mySforceConnection->create(array($sObject), 'Lead');

     print_r($createResponse);

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

I am receiving following error:

Error is "INVALID_FIELD: No such column 'first_name' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

  • Please help me. – Anjum Khalid Nov 18 '14 at 12:35
  • Can you post your code and what challenge you are having, are you getting an error? – Jenny B Nov 18 '14 at 14:57
  • I post code in Question. Error is "INVALID_FIELD: No such column 'first_name' on entity 'Lead'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names." – Anjum Khalid Nov 19 '14 at 5:29
2

I suspect you confused yourself by starting from the web-to-lead form.

That form is meant to be a quick and easy integration and an alternative to a proper SOAP API integration, where the Admin can generate the HTML, pass it to a web developer with no integration experience, the web dev can paste that HTML into a page on the companies web site, or some marketing landing page, tart it up with some CSS to look like the proper corporate branding and the company can collect leads.

Web-to-lead creates some html inputs named first_name and last_name, respectively, but these don't correspond to the true API names for those fields in the Lead object.

For proper documentation in any SOAP integration for standard objects, I would strongly suggest you use the SOAP API developer guide in the future. In it you will find extensive documentation on the current standard data model, including the Lead object. This is in the "Reference" section. If you look there, you will see that the proper API names for Lead First Name and Last Name are:

  • FirstName
  • LastName

So try to these two lines instead:

$sObject->FirstName = 'Smith';
$sObject->LastName = 'John';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.