Hi guys I am new to hubspot and still in learning phase.I am encounteringa problem when I add update function to my crud operation the some of the contacts donot get created(ie not inserted into database). It is taking first two contacts however i have to wait while to add another.However if I remove the update function, there is no problem in create.My code is posted below:
case self::CONTACT_CREATION:
Log::info(“WebhookController.SwitchCase@CONTACT_CREATION”, [“event”=> $event, “integration”=>$integration]);
//Get contact details form HB using object-id from webhook event
$contact = $integration->getContact($event->objectId)->getProperties();
Log::info(‘hs_contact’, [‘hs_contact’ => $contact]);
//Save contact to database
Contact::create([
‘hs_contact_id’ => $contact[‘hs_object_id’],
//include other columns as well.
‘contact_name’ => $contact[‘firstname’].’ '.$contact[‘lastname’],
‘contact_email’ => $contact[‘email’],
‘contact_phone’ => $contact[‘phone’],
]);
break;
case self::CONTACT_PROPERTY_CHANGE:
if ( Contact::where(‘hs_contact_id’, $event->objectId)->exists())
{
$contactdbId= $event->objectId;
$contactdb = Contact::where([[‘hs_contact_id’, $contactdbId]])->first();
Log::info(‘contact’, [‘contact’ => $contactdb]);
if ($event->propertyName ==‘phone’)
{
$contactdb->contact_phone=$event->propertyValue;
$contactdb->save();
}
if ( $event->propertyName === ‘firstname’)
{
$contactdb->contact_name=$event->propertyValue;
$contactdb->save();
}
if ( $event->propertyName === ‘email’)
{
$contactdb->contact_email=$event->propertyValue;
$contactdb->save();
}
}
else
{
return true;
}