AnsweredAssumed Answered

SugarCRM 6.5.16 CE: Duplicate Leads w/ Web to Lead Submission using CURL

Question asked by community-support on Jan 13, 2014
Latest reply on Aug 18, 2014 by Anil Purushothaman
Dear SugarCRM Community,

To collect leads from our landing pages, we're using customized forms where the lead is then submitted to SugarCRM via CURL (index.php?entryPoint=WebToLeadCapture).  So far this works great with the exception that the submissions are not checked for duplicate entries.  E.g if someone clicks twice on the form's submission button the lead is entered twice with two unique ids.  Is there any hidden field we need to include for the duplication check to work?  The only thing I've found so far is the field dup_checked = 1 but this will actually allow the entry of duplicate leads.

This is the code I am using:

[code]

//Get values of form fields

$salutation=implode(', ',$_POST['form']['Salutation']);

$first_name=$_POST['form']['FirstName'];

$last_name=$_POST['form']['LastName'];

$email1=$_POST['form']['Email'];

$phone_work=$_POST['form']['PhoneNumber'];

$primary_address_country=implode(', ',$_POST['form']['CountryCode']);

$lead_source_description ''; //Lead Source Description

$lead_source='Website';

$campaign_id=''; //Campaign ID

$assigned_user_id=''; //Assigned User ID

$redirect_url='';

$req_id='last_name;email1;';

//Prepare $PostFields array to send to SugarCRM using CURL

$PostFields=

'salutation='.$salutation

.'&first_name='.ucwords(strtolower($first_name))

.'&last_name='.ucwords(strtolower($last_name))

.'&email1='.$email1

.'&phone_work='.$phone_work

.'&description='.$description

.'&primary_address_country='.$primary_address_country

.'&lead_source_description='.$lead_source_description

.'&lead_source='.$lead_source

.'&campaign_id='.$campaign_id

.'&assigned_user_id='.$assigned_user_id

.'&redirect_url='.$redirect_url

.'&req_id='.$req_id;

//Send data to SugarCRM

$ch = curl_init('https://sugarcrmurl/index.php?entryPo...'); //SugarCRM URL

curl_setopt($ch, CURLOPT_TIMEOUT, 5);  //5 seconds timeout

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //Do not verify SSL certificate

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $PostFields);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_FAILONERROR,true);  //This is required for CURL to report 400 errors

$result=curl_exec($ch);

//Check for CURL submission errors

if(curl_errno($ch)) {

  //Error notifications go here

  }

else {

  //Submission was successful, close CURL Handle

  curl_close ($ch);

  }

[/code]

Any hints are highly appreciated!

Kind regards,

Romeo

(from sconsulting)

Outcomes