function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
needdevhelpneeddevhelp 

Not seeing an error, but no new lead

First I login and that has no issues. Then I create an array of field values and here is how I'm creating the lead:

Code:

$lead = array(
    'FirstName' => $firstname,
    'LastName' => $lastname,
    'Title' => $title,
    'Email' => $email,
    'Street' => $street

);
try {
  $addLeadResult = $sfdc->create("lead", $lead);
  echo $addLeadResult;
} catch (Exception $e) {
  global $errors;
  $errors = $e->faultstring;
  echo "Error Creating Lead: " . $e->faultstring . "<br/>";
}


 When this runs the output from the "echo $addLeadResult;" is "Object id #9".  I had plenty of errors getting this far so I know what the error messages look like.  This to me looks like success, but the new lead doesn't show up in Salesforce. 

Can you see what I'm doing wrong?

Tran ManTran Man
I believe you also need to specify the Company in a lead.  Rather than doing an echo, call print_r to dump the array out.

If you're not using a debugger, I would recommend that you do.


needdevhelp wrote:

First I login and that has no issues. Then I create an array of field values and here is how I'm creating the lead:

Code:

$lead = array(
    'FirstName' => $firstname,
    'LastName' => $lastname,
    'Title' => $title,
    'Email' => $email,
    'Street' => $street

);
try {
  $addLeadResult = $sfdc->create("lead", $lead);
  echo $addLeadResult;
} catch (Exception $e) {
  global $errors;
  $errors = $e->faultstring;
  echo "Error Creating Lead: " . $e->faultstring . "
"; }


 When this runs the output from the "echo $addLeadResult;" is "Object id #9".  I had plenty of errors getting this far so I know what the error messages look like.  This to me looks like success, but the new lead doesn't show up in Salesforce. 

Can you see what I'm doing wrong?




needdevhelpneeddevhelp

Thanks,

It's working now... 

one last thing.  When I submit a new lead via web-to-lead we had automatic emails going out to the new lead.  Is there someone way to trigger those emails from the API?  They are not going out now that I'm creating the lead via the API.