*/ class Target extends \Espo\Services\Record { public function convert(string $id): Entity { $entityManager = $this->getEntityManager(); $target = $this->getEntity($id); if (!$target) { throw new NotFound(); } if (!$this->getAcl()->check($target, 'delete')) { throw new Forbidden(); } if (!$this->getAcl()->check('Lead', 'read')) { throw new Forbidden(); } $lead = $entityManager->getNewEntity('Lead'); $lead->set($target->getValueMap()); $entityManager->removeEntity($target); $entityManager->saveEntity($lead); return $lead; } }