-
-
Notifications
You must be signed in to change notification settings - Fork 23
Creating a new entity
Zhmayev Yaroslav edited this page Nov 30, 2017
·
1 revision
Check if a lead record exists, by using the first and the last name as constraints:
// Look for Ivan Petrov among Leads
$ivanPetrovId = $client->entities->getNumericID('Leads', [
'firstname' => 'Ivan',
'lastname' => 'Petrov',
]);
// Add his record if it doesn't exist
if (intval($ivanPetrovId) < 1) {
$ivanPetrov = $client->entities->createOne('Leads', [
'salutationtype' => 'Mr.',
'firstname' => 'Ivan',
'lastname' => 'Petrov',
'phone' => "+7 495 4482237",
'fax' => "+7 495 3895096",
'company' => "ACME Ltd",
'email' => "roga-kopyta.ru",
'leadsource' => "Trade Show",
'website' => "roga-kopyta.ru",
'leadstatus' => "Cold",
]);
print_r($ivanPetrov);
} else {
echo('Ivan Petrov\'s record already exists!' . PHP_EOL);
}
// The output
Array
(
[salutationtype] => Mr.
[firstname] => Ivan
[lead_no] => LEA4
[phone] => +7 495 4482237
[lastname] => Petrov
[mobile] =>
[company] => ACME Ltd
[fax] => +7 495 3895096
[email] => roga-kopyta.ru
[leadsource] => Trade Show
[website] => roga-kopyta.ru
[leadstatus] => Cold
[annualrevenue] => 0.00000000
...
[id] => 10x9
)