I need to filter select list to select records in bottom panel, using a field from related entity, using this code:
Cananyone help me?
PHP Code:
<?php
namespace Espo\Custom\Classes\Select\Product\PrimaryFilters;
use Espo\Core\Select\Primary\Filter;
use Espo\ORM\Query\SelectBuilder;
use Espo\ORM\EntityManager;
class MyFilter implements Filter
{
public function apply(SelectBuilder $queryBuilder): void
{
$relatedEntityId = "HOW_TO_GET_IT"; // Get from referer entity
$entityID = $this->entityManager
->getRDBRepository('AnotherEntity')
->where([
'relatedEntityId' => $relatedEntityId,
])
->find();
$queryBuilder->where([
'relatedEntityFieldId=' => $entityId
]);
}
}
Comment