Hello,
we want to check on duplicates for a number in the entity + linked entity so that
- the same number can occurs more than one times
- but the same number can only appears once per linked entity
That code is already working, so that the person has the same name and the same unique field, then the duplicates dialogue appears.
This works:
The fields "name" and "uniqueField" are inside the entity "Test", this entity has a "n:1" relation to the other entity "Mandant". What we want to achieve is that the same unique number can only appears once per linked entity "Mandant".
This does not work:
So my question is how the linked entity can be included in the duplicate check?
Best regards,
Thomas Kutschker
P.s: Great CRM tool!
we want to check on duplicates for a number in the entity + linked entity so that
- the same number can occurs more than one times
- but the same number can only appears once per linked entity
That code is already working, so that the person has the same name and the same unique field, then the duplicates dialogue appears.
This works:
Code:
<?php namespace Espo\Custom\Services; use \Espo\ORM\Entity as Entity; class Kreditor extends \Espo\Core\Templates\Services\Base { protected function getDuplicateWhereClause(Entity $entity, $data) { return array( 'AND' => array( array( 'name' => $entity->get('name') ), array( 'uniqueField' => $entity->get('uniqueField'), ), ), ); } }
The fields "name" and "uniqueField" are inside the entity "Test", this entity has a "n:1" relation to the other entity "Mandant". What we want to achieve is that the same unique number can only appears once per linked entity "Mandant".
This does not work:
Code:
<?php namespace Espo\Custom\Services; use \Espo\ORM\Entity as Entity; class Kreditor extends \Espo\Core\Templates\Services\Base { protected function getDuplicateWhereClause(Entity $entity, $data) { return array( 'AND' => array( array( 'mandant' => $entity->get('mandant') ), array( 'uniqueField' => $entity->get('uniqueField'), ), ), ); } }
So my question is how the linked entity can be included in the duplicate check?
Best regards,
Thomas Kutschker
P.s: Great CRM tool!
Comment