How can I make a field that can not be duplicated?
Announcement
Collapse
No announcement yet.
Duplicate field
Collapse
X
-
I have problem with transforming "Lead" into "Account". When i directly add new "Account", there is error 409 and copy is not
How can i detect the duplicate phone numbers while converting the LEAD into ACCOUNT? Already did the duplicate checking in Creating accounts but the problem
Comment
-
In custom Lead service
https://forum.espocrm.com/forum/deve...d-into-account (here you can find the path)
Comment
-
Here is my code:
<?php
namespace Espo\Custom\Services;
class Lead extends \Espo\Modules\Crm\Services\Lead
{
protected function getDuplicateWhereClause(Entity $entity, $data = array())
{
return array(
'OR' => array(
array(
'phoneNumber' => '%' . $entity->get('phoneNumber') . '%'
),
array(
'emailAddress' => $entity->get('emailAddress'),
),
),
);
}
}
?>
on update I've got error: Bad ResponseLast edited by pavel_s; 05-22-2018, 02:24 PM.
Comment
-
Thats working code:
<?php
namespace Espo\Custom\Services;
use \Espo\ORM\Entity as Entity;
class Lead extends \Espo\Modules\Crm\Services\Lead
{
protected function getDuplicateWhereClause(Entity $entity, $data = array())
{
$data = array(
'OR' => array()
);
if ($entity->get('emailAddress')) {
$data['OR'][] = array(
'emailAddress' => $entity->get('emailAddress'),
);
}
if ($entity->get('phoneNumber')) {
$data['OR'][] = array(
'phoneNumber' => '%' . $entity->get('phoneNumber') . '%'
);
}
return $data;
}
}
?>
Comment
Comment