How to get referer entity id using primaryfilter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • criffoh
    Member
    • Jun 2020
    • 55

    How to get referer entity id using primaryfilter

    I need to filter select list to select records in bottom panel, using a field from related entity, using this code:

    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
            ]);
    
        }
    
    }
    Cananyone help me?
  • yuri
    Member
    • Mar 2014
    • 8471

    #2
    It's not possible by design. https://forum.espocrm.com/forum/deve...primary-filter
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...